1.0.4
Introducing nwire
nwire
allows you to use dependency injection easily in your projects. Create a Container
, register dependencies, generate a Context
and you now have a fully wired system that resolves dependencies when needed.
import { Container, Injected } from "nwire"
type MyTypedContext = {
banner: string
my: MyService
}
export class MyService extends Injected<MyTypedContext> {
helloWorld() {
return this.context.banner
}
}
const context = Container.register("banner", () => "Hello world!")
.instance("my", MyService)
.context()
console.log(context.my.helloWorld()) // => console output: "Hello world!"
More information on the README.md!