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);
|
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>(
|
public async setSetting<T extends keyof SyncSettings>(
|
||||||
key: T,
|
key: T,
|
||||||
value: SyncSettings[T]
|
value: SyncSettings[T]
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,15 @@ export class WebSocketManager {
|
||||||
this.remoteCursorsUpdateListeners.push(listener);
|
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 {
|
public start(): void {
|
||||||
this.isStopped = false;
|
this.isStopped = false;
|
||||||
this._isFirstSyncCompleted = false;
|
this._isFirstSyncCompleted = false;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,15 @@ export class FileChangeNotifier {
|
||||||
this.listeners.push(listener);
|
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 {
|
public notifyOfFileChange(filePath: RelativePath): void {
|
||||||
this.listeners.forEach((listener) => listener(filePath));
|
this.listeners.forEach((listener) => listener(filePath));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,15 @@ export class Syncer {
|
||||||
this.remainingOperationsListeners.push(listener);
|
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(
|
public async syncLocallyCreatedFile(
|
||||||
relativePath: RelativePath
|
relativePath: RelativePath
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,15 @@ export class Logger {
|
||||||
this.onMessageListeners.push(listener);
|
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 {
|
public reset(): void {
|
||||||
this.messages.length = 0;
|
this.messages.length = 0;
|
||||||
this.debug("Logger has been reset");
|
this.debug("Logger has been reset");
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,15 @@ export class SyncHistory {
|
||||||
listener({ ...this.status });
|
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 {
|
public reset(): void {
|
||||||
this._entries.length = 0;
|
this._entries.length = 0;
|
||||||
this.status = {
|
this.status = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue