https://github.com/qiwi/di-container
Experiments around DI and IoC
https://github.com/qiwi/di-container
js-platform
Last synced: 2 months ago
JSON representation
Experiments around DI and IoC
- Host: GitHub
- URL: https://github.com/qiwi/di-container
- Owner: qiwi
- License: mit
- Created: 2018-02-26T16:58:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-02-09T12:14:01.000Z (3 months ago)
- Last Synced: 2025-02-09T13:22:43.880Z (3 months ago)
- Topics: js-platform
- Language: JavaScript
- Size: 482 KB
- Stars: 0
- Watchers: 11
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# di-container
Experiments around DI and IoC[](http://standardjs.com)
[](https://travis-ci.org/qiwi/di-container)
[](https://coveralls.io/github/qiwi/di-container)
[](https://david-dm.org/qiwi/di-container)
[](https://david-dm.org/qiwi/di-container)##### Motivation
DI/IoC is nice and useful idea. There're several good JS implementations of this concept:
1. [Inversify](https://github.com/inversify/InversifyJS)
2. [Awilix](https://github.com/jeffijoe/awilix) and [Jeff's great article](https://medium.com/p/f2a88efdd427)
...
15. [di-decorators](https://github.com/lgvo/di-decorators) by Luis Gustavo Vilela de Oliveira
16. [js-ioc-container](https://github.com/andene/js-ioc-container) by Andreas KihlbergBut nothing is perfect.
So we need yet another one DI container absolutely incompatible with others.##### DI must be simple
```javascript
import {Container, CLASS} from 'di-container'class Bar {
baz() {return 'qux'}
}
class Foo {
constructor (bar) {
this.bar = bar
}
}const container = new Container()
container.register(Bar, {type: CLASS})
container.register(Foo, {deps: [Bar], type: CLASS})const foo = container.get(Foo)
const qux = foo.bar.baz();
```##### Research area
1. Scopes
2. Proxies
3. Aliases
4. Lazy consistency check
5. Decorators