1 | import { Lookup } from "./lookup";
|
2 | var ModuleActivationStore = (function () {
|
3 | function ModuleActivationStore() {
|
4 | this._map = new Map();
|
5 | }
|
6 | ModuleActivationStore.prototype.remove = function (moduleId) {
|
7 | if (this._map.has(moduleId)) {
|
8 | var handlers = this._map.get(moduleId);
|
9 | this._map.delete(moduleId);
|
10 | return handlers;
|
11 | }
|
12 | return this._getEmptyHandlersStore();
|
13 | };
|
14 | ModuleActivationStore.prototype.addDeactivation = function (moduleId, serviceIdentifier, onDeactivation) {
|
15 | this._getModuleActivationHandlers(moduleId)
|
16 | .onDeactivations.add(serviceIdentifier, onDeactivation);
|
17 | };
|
18 | ModuleActivationStore.prototype.addActivation = function (moduleId, serviceIdentifier, onActivation) {
|
19 | this._getModuleActivationHandlers(moduleId)
|
20 | .onActivations.add(serviceIdentifier, onActivation);
|
21 | };
|
22 | ModuleActivationStore.prototype.clone = function () {
|
23 | var clone = new ModuleActivationStore();
|
24 | this._map.forEach(function (handlersStore, moduleId) {
|
25 | clone._map.set(moduleId, {
|
26 | onActivations: handlersStore.onActivations.clone(),
|
27 | onDeactivations: handlersStore.onDeactivations.clone(),
|
28 | });
|
29 | });
|
30 | return clone;
|
31 | };
|
32 | ModuleActivationStore.prototype._getModuleActivationHandlers = function (moduleId) {
|
33 | var moduleActivationHandlers = this._map.get(moduleId);
|
34 | if (moduleActivationHandlers === undefined) {
|
35 | moduleActivationHandlers = this._getEmptyHandlersStore();
|
36 | this._map.set(moduleId, moduleActivationHandlers);
|
37 | }
|
38 | return moduleActivationHandlers;
|
39 | };
|
40 | ModuleActivationStore.prototype._getEmptyHandlersStore = function () {
|
41 | var handlersStore = {
|
42 | onActivations: new Lookup(),
|
43 | onDeactivations: new Lookup()
|
44 | };
|
45 | return handlersStore;
|
46 | };
|
47 | return ModuleActivationStore;
|
48 | }());
|
49 | export { ModuleActivationStore };
|
50 |
|
\ | No newline at end of file |