hadron-app-registry
Advanced tools
Comparing version 6.0.0 to 7.0.0
'use strict'; | ||
const Reflux = require('reflux'); | ||
const EventEmitter = require('events'); | ||
const Action = require('./actions'); | ||
@@ -23,22 +24,5 @@ | ||
*/ | ||
class AppRegistry { | ||
class AppRegistry extends EventEmitter { | ||
/** | ||
* Executes the provided function against all stores in the registry. | ||
* | ||
* @param {Function} fn - The function | ||
* | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
callOnStores(fn) { | ||
for (let key in this.stores) { | ||
if (this.stores.hasOwnProperty(key)) { | ||
const store = this.stores[key]; | ||
fn(store); | ||
} | ||
} | ||
return this; | ||
} | ||
/** | ||
* Instantiate the registry. | ||
@@ -49,2 +33,3 @@ * | ||
constructor() { | ||
super(); | ||
this.actions = {}; | ||
@@ -193,3 +178,3 @@ this.components = {}; | ||
onActivated() { | ||
return this.callOnStores((store) => { | ||
return this._callOnStores((store) => { | ||
if (store.onActivated) { | ||
@@ -202,33 +187,2 @@ store.onActivated(this); | ||
/** | ||
* Calls onConnected on all the stores in the registry. | ||
* | ||
* @param {Error} error - The possible error. | ||
* @param {DataService} dataService - The connected data service. | ||
* | ||
* @returns {AppRegistry} The app registry. | ||
*/ | ||
onConnected(error, dataService) { | ||
return this.callOnStores((store) => { | ||
if (store.onConnected) { | ||
store.onConnected(error, dataService); | ||
} | ||
}); | ||
} | ||
/** | ||
* Calls onDataServiceInitialized on all the stores in the registry. | ||
* | ||
* @param {DataService} dataService - The data service before connection. | ||
* | ||
* @returns {AppRegistry} The app registry. | ||
*/ | ||
onDataServiceInitialized(dataService) { | ||
return this.callOnStores((store) => { | ||
if (store.onDataServiceInitialized) { | ||
store.onDataServiceInitialized(dataService); | ||
} | ||
}); | ||
} | ||
/** | ||
* Register an action in the registry. | ||
@@ -327,2 +281,12 @@ * | ||
_callOnStores(fn) { | ||
for (let key in this.stores) { | ||
if (this.stores.hasOwnProperty(key)) { | ||
const store = this.stores[key]; | ||
fn(store); | ||
} | ||
} | ||
return this; | ||
} | ||
_roleComparator(a, b) { | ||
@@ -329,0 +293,0 @@ const aOrder = a.order || INT8_MAX; |
@@ -7,3 +7,3 @@ { | ||
"homepage": "https://github.com/mongodb-js/hadron-app-registry", | ||
"version": "6.0.0", | ||
"version": "7.0.0", | ||
"repository": { | ||
@@ -10,0 +10,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23868
460