Skip to content

dependency injection made super easy - all you need | lazy register | with override | decorator support

Notifications You must be signed in to change notification settings

nenjack/inject.min

Repository files navigation

inject.min

dependency injection made super easy - all you need | lazy register | with override | decorator support

npm version build status

Installation

yarn add inject.min

Usage

import { Inject } from 'inject.min';

class Example {
  // your content
}

class Class {
  @Inject(Example) prop!: Example;

  constructor() {
    // exists
    console.log(this.prop);
  }
}

const class1 = new Class();
const class2 = new Class();

// true
console.log(class1.prop === class2.prop);

tsconfig.json

you need to have compiler option experimental decorators enabled in tsconfig.json

{
  "compilerOptions": {
    "experimentalDecorators": true
  }
}

API

DIContainer Documentation

License

MIT