backbone-di
Installing backbone-di
The package can be installed through npm or bower.
Using npm
npm install backbone-di
Using bower
bower install backbone-di
After installing the package, you can grab the backbone-di.js
or the minified version of it backbone-di.min.js
Usage examples
Bindings
// Create an instance of Backbone.Injectorvar injector = ; // Bind a value which can be of any type, returns the string R. Moormaninjector; // Bind a type which returns every time a new instanceinjector; // Bind a type to a singleton which returns only one instance of itinjector;
Injections
// Create an instance of Backbone.Injectorvar injector = ; // Let's do some bindings...injector; // Create a new Backbone.View with the config injectedvar view = new BackboneView; injector; // Retrieve the config title by the key which is determined in the// config, in this case that will be 'config'.var title = viewconfigtitle;
Note that the key in the config of injections
will be the property name
under which the instance is injected.
Changelog
0.1.0
- Prototype