hadron-app-registry
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -79,2 +79,31 @@ 'use strict'; | ||
/** | ||
* The action for a container being deregistered. | ||
*/ | ||
const containerDeregistered = Reflux.createAction({ | ||
/** | ||
* Log the action. | ||
* | ||
* @param {String} name - The container name. | ||
*/ | ||
preEmit: function(name) { | ||
debug(`Container ${name} deregistered.`); | ||
} | ||
}); | ||
/** | ||
* The action for a container being registered. | ||
*/ | ||
const containerRegistered = Reflux.createAction({ | ||
/** | ||
* Log the action. | ||
* | ||
* @param {String} name - The container name. | ||
*/ | ||
preEmit: function(name) { | ||
debug(`Container ${name} registered.`); | ||
} | ||
}); | ||
/** | ||
* The action for a component being overridden. | ||
@@ -94,2 +123,31 @@ */ | ||
/** | ||
* The action for a role being deregistered. | ||
*/ | ||
const roleDeregistered = Reflux.createAction({ | ||
/** | ||
* Log the action. | ||
* | ||
* @param {String} name - The role name. | ||
*/ | ||
preEmit: function(name) { | ||
debug(`Role ${name} deregistered.`); | ||
} | ||
}); | ||
/** | ||
* The action for a role being registered. | ||
*/ | ||
const roleRegistered = Reflux.createAction({ | ||
/** | ||
* Log the action. | ||
* | ||
* @param {String} name - The role name. | ||
*/ | ||
preEmit: function(name) { | ||
debug(`Role ${name} registered.`); | ||
} | ||
}); | ||
/** | ||
* The action for a store being deregistered. | ||
@@ -143,4 +201,8 @@ */ | ||
module.exports.componentOverridden = componentOverridden; | ||
module.exports.containerDeregistered = containerDeregistered; | ||
module.exports.containerRegistered = containerRegistered; | ||
module.exports.roleDeregistered = roleDeregistered; | ||
module.exports.roleRegistered = roleRegistered; | ||
module.exports.storeDeregistered = storeDeregistered; | ||
module.exports.storeRegistered = storeRegistered; | ||
module.exports.storeOverridden = storeOverridden; |
@@ -13,2 +13,4 @@ 'use strict'; | ||
* Instantiate the registry. | ||
* | ||
* @todo: Package manager activates at end. | ||
*/ | ||
@@ -19,2 +21,4 @@ constructor() { | ||
this.stores = {}; | ||
this.containers = {}; | ||
this.roles = {}; | ||
} | ||
@@ -27,3 +31,3 @@ | ||
* | ||
* @returns {ComponentRegistry} This instance. | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
@@ -41,3 +45,3 @@ deregisterAction(name) { | ||
* | ||
* @returns {ComponentRegistry} This instance. | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
@@ -51,2 +55,32 @@ deregisterComponent(name) { | ||
/** | ||
* Deregister a container. | ||
* | ||
* @param {String} name - The container name. | ||
* @param {Component} component - The container to deregister. | ||
* | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
deregisterContainer(name, component) { | ||
const containers = this.containers[name]; | ||
containers.splice(containers.indexOf(component), 1); | ||
Action.containerDeregistered(name); | ||
return this; | ||
} | ||
/** | ||
* Deregister a role. | ||
* | ||
* @param {String} name - The role name. | ||
* @param {Object} object - The role to deregister. | ||
* | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
deregisterRole(name, object) { | ||
const roles = this.roles[name]; | ||
roles.splice(roles.indexOf(object), 1); | ||
Action.roleDeregistered(name); | ||
return this; | ||
} | ||
/** | ||
* Deregister a store. | ||
@@ -56,3 +90,3 @@ * | ||
* | ||
* @returns {ComponentRegistry} This instance. | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
@@ -77,2 +111,13 @@ deregisterStore(name) { | ||
/** | ||
* Get a container by name. | ||
* | ||
* @param {String} name - The container name. | ||
* | ||
* @returns {Array} The container components. | ||
*/ | ||
getContainer(name) { | ||
return this.containers[name]; | ||
} | ||
/** | ||
* Get a component by name. | ||
@@ -89,2 +134,13 @@ * | ||
/** | ||
* Get a role by name. | ||
* | ||
* @param {String} name - The role name. | ||
* | ||
* @returns {Array} The role components. | ||
*/ | ||
getRole(name) { | ||
return this.roles[name]; | ||
} | ||
/** | ||
* Get a store by name. | ||
@@ -106,3 +162,3 @@ * | ||
* | ||
* @returns {ComponentRegistry} This instance. | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
@@ -121,2 +177,20 @@ registerAction(name, action) { | ||
/** | ||
* Register a container. | ||
* | ||
* @param {String} name - The container name. | ||
* @param {Component} container - The container component. | ||
* | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
registerContainer(name, container) { | ||
if (this.containers.hasOwnProperty(name) && !this.containers[name].includes(container)) { | ||
this.containers[name].push(container); | ||
} else { | ||
this.containers[name] = [ container ]; | ||
} | ||
Action.containerRegistered(name); | ||
return this; | ||
} | ||
/** | ||
* Register a component in the registry. | ||
@@ -127,3 +201,3 @@ * | ||
* | ||
* @returns {ComponentRegistry} This instance. | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
@@ -142,2 +216,20 @@ registerComponent(name, component) { | ||
/** | ||
* Register a role. | ||
* | ||
* @param {String} name - The role name. | ||
* @param {Object} role - The role object. | ||
* | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
registerRole(name, role) { | ||
if (this.roles.hasOwnProperty(name) && !this.roles[name].includes(role)) { | ||
this.roles[name].push(role); | ||
} else { | ||
this.roles[name] = [ role ]; | ||
} | ||
Action.roleRegistered(name); | ||
return this; | ||
} | ||
/** | ||
* Register a store in the registry. | ||
@@ -148,3 +240,3 @@ * | ||
* | ||
* @returns {ComponentRegistry} This instance. | ||
* @returns {AppRegistry} This instance. | ||
*/ | ||
@@ -161,5 +253,4 @@ registerStore(name, store) { | ||
} | ||
} | ||
module.exports = AppRegistry; |
@@ -7,3 +7,3 @@ { | ||
"homepage": "https://github.com/mongodb-js/hadron-app-registry", | ||
"version": "4.0.0", | ||
"version": "4.1.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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22608
413
0