Component and other handler deregisterations

This commit is contained in:
Mo Bitar
2020-03-24 12:12:07 -05:00
parent ee7cb1fce6
commit 7aa38cbdb8
11 changed files with 476 additions and 310 deletions

View File

@@ -1,8 +1,7 @@
/* eslint-disable camelcase */
// An interface used by the Desktop app to interact with SN
import pull from 'lodash/pull';
import { isDesktopApplication } from '@/utils';
import { EncryptionIntents, ApplicationService, ApplicationEvents } from 'snjs';
import { EncryptionIntents, ApplicationService, ApplicationEvents, removeFromArray } from 'snjs';
const COMPONENT_DATA_KEY_INSTALL_ERROR = 'installError';
const COMPONENT_CONTENT_KEY_PACKAGE_INFO = 'package_info';
@@ -89,7 +88,9 @@ export class DesktopManager extends ApplicationService {
callback: callback
};
this.updateObservers.push(observer);
return observer;
return () => {
removeFromArray(this.updateObservers, observer);
};
}
searchText(text) {
@@ -106,10 +107,6 @@ export class DesktopManager extends ApplicationService {
}
}
deregisterUpdateObserver(observer) {
pull(this.updateObservers, observer);
}
// Pass null to cancel search
desktop_setSearchHandler(handler) {
this.searchHandler = handler;
@@ -161,7 +158,7 @@ export class DesktopManager extends ApplicationService {
}
desktop_deregisterComponentActivationObserver(observer) {
pull(this.componentActivationObservers, observer);
removeFromArray(this.componentActivationObservers, observer);
}
/* Notify observers that a component has been registered/activated */