Add remove event listener methods
This commit is contained in:
parent
d4b68154df
commit
91675ea99c
6 changed files with 54 additions and 0 deletions
|
|
@ -59,6 +59,15 @@ export class Settings {
|
|||
this.onSettingsChangeHandlers.push(listener);
|
||||
}
|
||||
|
||||
public removeOnSettingsChangeListener(
|
||||
listener: (settings: SyncSettings, oldSettings: SyncSettings) => unknown
|
||||
): void {
|
||||
const index = this.onSettingsChangeHandlers.indexOf(listener);
|
||||
if (index !== -1) {
|
||||
this.onSettingsChangeHandlers.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public async setSetting<T extends keyof SyncSettings>(
|
||||
key: T,
|
||||
value: SyncSettings[T]
|
||||
|
|
|
|||
|
|
@ -74,6 +74,15 @@ export class WebSocketManager {
|
|||
this.remoteCursorsUpdateListeners.push(listener);
|
||||
}
|
||||
|
||||
public removeRemoteCursorsUpdateListener(
|
||||
listener: (cursors: ClientCursors[]) => unknown
|
||||
): void {
|
||||
const index = this.remoteCursorsUpdateListeners.indexOf(listener);
|
||||
if (index !== -1) {
|
||||
this.remoteCursorsUpdateListeners.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public start(): void {
|
||||
this.isStopped = false;
|
||||
this._isFirstSyncCompleted = false;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,15 @@ export class FileChangeNotifier {
|
|||
this.listeners.push(listener);
|
||||
}
|
||||
|
||||
public removeFileChangeListener(
|
||||
listener: (filePath: RelativePath) => unknown
|
||||
): void {
|
||||
const index = this.listeners.indexOf(listener);
|
||||
if (index !== -1) {
|
||||
this.listeners.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public notifyOfFileChange(filePath: RelativePath): void {
|
||||
this.listeners.forEach((listener) => listener(filePath));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,15 @@ export class Syncer {
|
|||
this.remainingOperationsListeners.push(listener);
|
||||
}
|
||||
|
||||
public removeRemainingOperationsListener(
|
||||
listener: (remainingOperations: number) => unknown
|
||||
): void {
|
||||
const index = this.remainingOperationsListeners.indexOf(listener);
|
||||
if (index !== -1) {
|
||||
this.remainingOperationsListeners.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public async syncLocallyCreatedFile(
|
||||
relativePath: RelativePath
|
||||
): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ export class Logger {
|
|||
this.onMessageListeners.push(listener);
|
||||
}
|
||||
|
||||
public removeOnMessageListener(
|
||||
listener: (message: LogLine) => unknown
|
||||
): void {
|
||||
const index = this.onMessageListeners.indexOf(listener);
|
||||
if (index !== -1) {
|
||||
this.onMessageListeners.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this.messages.length = 0;
|
||||
this.debug("Logger has been reset");
|
||||
|
|
|
|||
|
|
@ -119,6 +119,15 @@ export class SyncHistory {
|
|||
listener({ ...this.status });
|
||||
}
|
||||
|
||||
public removeSyncHistoryUpdateListener(
|
||||
listener: (stats: HistoryStats) => unknown
|
||||
): void {
|
||||
const index = this.syncHistoryUpdateListeners.indexOf(listener);
|
||||
if (index !== -1) {
|
||||
this.syncHistoryUpdateListeners.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this._entries.length = 0;
|
||||
this.status = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue