Added component activation/register observers
This commit is contained in:
@@ -808,6 +808,8 @@ class ComponentManager {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.postActiveThemeToComponent(component);
|
this.postActiveThemeToComponent(component);
|
||||||
|
|
||||||
|
this.desktopManager.notifyComponentActivation(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Performs func in timeout, but syncronously, if used `await waitTimeout` */
|
/* Performs func in timeout, but syncronously, if used `await waitTimeout` */
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class DesktopManager {
|
|||||||
this.$rootScope = $rootScope;
|
this.$rootScope = $rootScope;
|
||||||
this.timeout = $timeout;
|
this.timeout = $timeout;
|
||||||
this.updateObservers = [];
|
this.updateObservers = [];
|
||||||
|
this.activationObservers = [];
|
||||||
|
|
||||||
this.isDesktop = isDesktopApplication();
|
this.isDesktop = isDesktopApplication();
|
||||||
|
|
||||||
@@ -106,7 +107,26 @@ class DesktopManager {
|
|||||||
for(var observer of this.updateObservers) {
|
for(var observer of this.updateObservers) {
|
||||||
observer.callback(component);
|
observer.callback(component);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
desktop_registerActivationObserver(callback) {
|
||||||
|
var observer = {id: Math.random, callback: callback};
|
||||||
|
this.activationObservers.push(observer);
|
||||||
|
return observer;
|
||||||
|
}
|
||||||
|
|
||||||
|
desktop_deregisterActivationObserver(observer) {
|
||||||
|
_.pull(this.activationObservers, observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Notify observers that a component has been registered/activated */
|
||||||
|
notifyComponentActivation(component) {
|
||||||
|
this.timeout(() => {
|
||||||
|
for(var observer of this.activationObservers) {
|
||||||
|
observer.callback(component);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used to resolve "sn://" */
|
/* Used to resolve "sn://" */
|
||||||
|
|||||||
Reference in New Issue
Block a user