0.3.22-beta.4 • Published 10 months ago
@typed-inject/injector v0.3.22-beta.4
TypeDI++
Elegant Dependency Injection in JavaScript and TypeScript.
Optional
,SkipSelf
,Self
,Many
support; just like Angular!- Purely functional injection without any runtime reflection.
- Strict integration with TypeScript.
- Easy testability with the Container-based API.
- Rigorously tested API (nearly 100% coverage!)
- 🔥 10 kB bundle size. (no dependencies!)
(The only thing it can't do is make coffee.)
Dependency Injection in 23 lines:
import { Service, Container } from '@typed-inject/injector';
// Make a service that logs a message to the console.
@Service([])
class LogService {
log(message: string) {
console.log(message);
}
}
// Then, use our logging service in our root service,
// which will log "hello world!" to the console.
@Service([LogService])
class RootService {
// Store the instance of the logger inside the class.
constructor(private logger: LogService) {}
run() {
this.logger.log('hello world!');
}
}
// Now, run our service!
Container.get(RootService).run();
Congrats! You've just mastered DI in 23 lines. To learn more, check out the documentation!
License
Released under MIT by @freshgum & upstream TypeDI contributors.
0.3.22-beta.4
10 months ago
0.3.22-beta.3
10 months ago
0.3.22-beta.2
10 months ago
0.3.22-beta.1
10 months ago
0.3.22-beta.0
10 months ago
0.3.0
10 months ago
0.3.2
10 months ago
0.3.1
10 months ago
0.3.21
10 months ago
0.2.0
11 months ago