esrol-initializer
An Initializer Class used for adding and initializing components. Priority must exist between them.
Part of Esrol
Installation
$ npm install --save esrol-initializer
Usage
'use strict';let Initializer = ;let initializer = ; let foo = priority: 1 { console; }; let promise = { // some async stuff ;}; promise; let promisifiedComponent = priority: 2 { console; return promise; }; let bar = priority: 3 { console; }; let { console;}; initializer;initializer;initializer;initializer;initializer;
Methods
- setCallback(fn) ⇒
boolean
Set a callback which will be called when all components are resolved.
- registerComponent(component) ⇒
boolean
Register a new component object. Re-sort (re-prioritize) components with the new one.
- instantiateComponents()
Instantiate all components.
boolean
Set a callback which will be called when all components are
resolved.
Returns: boolean
- true - on success
Throws:
error
error - if parameter is not a function
Param | Type | Description |
---|---|---|
fn | function |
the callback function that needs to be executed when all components are resolved |
boolean
registerComponent(component) ⇒ Register a new component object. Re-sort (re-prioritize) components with the new one.
Returns: boolean
- true - on success
Throws:
error
error - if component object isn't as expected
Param | Type | Description |
---|---|---|
component | object |
holds two properties - { priority: 1, component: function() {} } |
instantiateComponents()
Instantiate all components.
Contriubtion
Any contribution will be highly appreciated. Just make sure that:
- Your code works.
- You have 100% successful tests coverage.
- You have comments in your code.
- Follows eslint config. Exceptions are possible where that make sense.
Tests
To run the test suite, first install the dependencies, then run npm test
:
$ npm install$ npm test