Extremely thin, async dependency injection, now with a getting started guide.
- async dependency resolution
- constructor and property injection
- modular containers with inheritance
- named dependencies using strings or unique symbols
- typed errors
- typescript typedefs
- zero runtime dependencies, bundled or otherwise
- extensive test coverage
Server class that needs to fetch data from the
Filesystem, but doesn't know (or need to
know) how those are implemented. The following example is also part of the unit tests.
;;/*** Constructors, strings, and symbols are supported. Symbols are* preferred, as the most unique, but names can be convenient.*/;
noicejs will collect dependencies from the decorated constructor and any superclasses, find a provider for each injected dependency, and asynchronously resolve them before calling the constructor. Any extra parameters are passed on to the original constructor, along with the container and resolved dependencies.
To build a bundle and run tests:
> makeyarnyarn install v1.17.3[1/4] Resolving packages...success Already up-to-date.Done in 0.20s./home/ssube/code/ssube/noicejs//node_modules/.bin/rollup --config /home/ssube/code/ssube/noicejs//config/rollup.jssrc/index.ts, test/harness.ts, test/**/Test*.ts → out/......created out/ in 3.3s/home/ssube/code/ssube/noicejs//node_modules/.bin/api-extractor run --config /home/ssube/code/ssube/noicejs//config/api-extractor.json --local -vapi-extractor 7.3.8 - https://api-extractor.com/...API Extractor completed successfullySuccess!