Skip to content

1.0.4

Compare
Choose a tag to compare
@divmgl divmgl released this 26 Oct 18:22
· 10 commits to master since this release
84b1070

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!