Switched to serialized version of component to component activation observers

This commit is contained in:
Bryan Chauvin
2018-10-08 12:45:27 -04:00
parent 832a770c2f
commit e9c2a8bef2

View File

@@ -10,7 +10,7 @@ class DesktopManager {
this.$rootScope = $rootScope;
this.timeout = $timeout;
this.updateObservers = [];
this.activationObservers = [];
this.componentActivationObservers = [];
this.isDesktop = isDesktopApplication();
@@ -110,21 +110,23 @@ class DesktopManager {
});
}
desktop_registerActivationObserver(callback) {
desktop_registerComponentActivationObserver(callback) {
var observer = {id: Math.random, callback: callback};
this.activationObservers.push(observer);
this.componentActivationObservers.push(observer);
return observer;
}
desktop_deregisterActivationObserver(observer) {
_.pull(this.activationObservers, observer);
desktop_deregisterComponentActivationObserver(observer) {
_.pull(this.componentActivationObservers, observer);
}
/* Notify observers that a component has been registered/activated */
notifyComponentActivation(component) {
async notifyComponentActivation(component) {
var serializedComponent = await this.convertComponentForTransmission(component);
this.timeout(() => {
for(var observer of this.activationObservers) {
observer.callback(component);
for(var observer of this.componentActivationObservers) {
observer.callback(serializedComponent);
}
});
}