Injectoid
Injectoid helps you to compose your app using modules
Installing
npm:
npm install injectoid
var Injectoid = Injectoid;
browsers:
Should work with require.js and common.js (not tested)
or
Works as global Injectoid
constructor
Usage
var app = ; app; app;
API
Constructor
Creates new Injectoid instance. Should be used with new
var app = ;
app.provide(moduleName, provider);
Adds module to app with specified moduleName
.
-
moduleName: [string]
. Used to name module in an app. -
provider: [function | object | value]
. Can be a factory function, or just plain JavaScript value/object.-
If function form is used, DI feature becomes available.
-
NOTE: function MUST return some value/object, so module can be treated as available.
-
Required modules become available as arguments of
provider
function. -
If some required modules are not available,
provider
function is put into a queue, until all required modules are available.
-
-
If value/object form is used, module gets immediately available as
moduleName
-
app.run(resolvable);
Calls resolvable
with resolved modules. Useful if you need to obtain a reference to some module, or call something just once.
resolvable: [function]
. Called with resolved modules as arguments.- If some required modules are not available,
resolvable
function is put into a queue, as inapp.provide
case.
- If some required modules are not available,
License
The MIT License (MIT)