https://github.com/aackerman/container
https://github.com/aackerman/container
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/aackerman/container
- Owner: aackerman
- License: mit
- Created: 2015-01-17T04:20:11.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-22T01:47:34.000Z (over 11 years ago)
- Last Synced: 2024-04-15T03:02:15.843Z (about 2 years ago)
- Language: JavaScript
- Size: 160 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## container
Container, Registry, Resolver Dependency Injection.
Lifted from Ember and modified to work without certain Ember assumptions and dependencies.
A Container retains a cache of instance objects, a Registry retains a cache of constructor/factory objects and type injections, a Resolver is used to locate constructor/factory objects on a global namespace or within a module system. This allows mapping a `type:name` formatted string to a value on a global namespace or an exported module value.
### Resolving on a namespace
```
class App extends Namespace {
constructor(options) {
super(options);
}
getSerializer() {
return this.__container__.lookup('serializers:application', {
singleton: false
});
}
};
App.ApplicationSerializer = function(){};
var app = new App();
var s = app.getSerializer();
s instanceof App.ApplicationSerializer; // true
```