mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 09:35:36 -05:00
API improvement: make registerConnectionEventProvider return disposable (#11880)
* promote api to official * add comments * disposable * move getConnection out * comment for connection namespace * remove extra line * also fix registerQueryInfoHandler
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
import { ExtHostConnectionManagementShape, SqlMainContext, MainThreadConnectionManagementShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import * as azdata from 'azdata';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
|
||||
export class ExtHostConnectionManagement extends ExtHostConnectionManagementShape {
|
||||
|
||||
@@ -27,10 +29,15 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
|
||||
}
|
||||
}
|
||||
|
||||
public $registerConnectionEventListener(providerId: string, listener: azdata.connection.ConnectionEventListener): void {
|
||||
this._connectionListeners[this._nextListenerHandle] = listener;
|
||||
this._proxy.$registerConnectionEventListener(this._nextListenerHandle, providerId);
|
||||
this._nextListenerHandle++;
|
||||
public $registerConnectionEventListener(listener: azdata.connection.ConnectionEventListener): IDisposable {
|
||||
const handle = this._nextListenerHandle++;
|
||||
this._connectionListeners[handle] = listener;
|
||||
this._proxy.$registerConnectionEventListener(handle);
|
||||
|
||||
return new Disposable(() => {
|
||||
this._connectionListeners.delete(handle);
|
||||
this._proxy.$unregisterConnectionEventListener(handle);
|
||||
});
|
||||
}
|
||||
|
||||
public $getCurrentConnection(): Thenable<azdata.connection.ConnectionProfile> {
|
||||
|
||||
Reference in New Issue
Block a user