Dependency injection container for Ogre Tools
A brutal dependency injection container
Usage
$ npm install @ogre-tools/injectable
...
import { createContainer } from '@ogre-tools/injectable';
Usage
it('given an injectable is registered, when injected, injects', () => {
const di = createContainer();
const someInjectable = getInjectable({
id: 'some-id',
instantiate: () => 'some-instance',
});
di.register(someInjectable);
const actual = di.inject(someInjectable);
expect(actual).toBe('some-instance');
});
Documentation
Check unit tests for documentation.
15.0.0 (2023-02-20)
⚠ BREAKING CHANGES
injectable-react
now requires registerInjectableReact(di)
to work.- Identify injectables and tokens by reference instead of id to permit namespaces later
- Make flow not automatically await for promises in arrays
Features
- Identify injectables and tokens by reference instead of id to permit namespaces later (72487e2)
- Include "scope" of injectable in typing (6a81e7c)
- Introduce "di.injectManyWithMeta()" to permit reuse of injectable id in implementation code (94fed1e)
- Introduce "generable" (ie. generator library X) as package (bd1b8c7)
- Introduce combinations in fp (88f0617)
- Introduce matchAll in fp (000b23e)
- Introduce movingWindow in fp (1f212c0)
- Introduce relationJoin in fp (09ee015)
- Introduce replaceTagsWithValues in fp (235be79)
- Introduce scopes for injectables to initially serve as namespaces (d773e34)
- Make flow not automatically await for promises in arrays (9752ef4)
- Remove too complex concept of "ad-hoc"-injectables (ie. injectable without registration) (3baaf04)
14.0.3 (2022-11-23)
Note: Version bump only for package ogre-tools
14.0.2 (2022-11-23)
Note: Version bump only for package ogre-tools
14.0.1 (2022-11-23)
Note: Version bump only for package ogre-tools