Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@newdash/inject

newdash176MIT0.2.31TypeScript support: included

typescript dependency inject container

newdash, dependency injection, di, IoC

readme

Dependency Inject Container

npm (scoped) Codecov Netlify Quality Gate Status Security Rating

Yet another dependency injection container for typescript

Quick Start

# install libs
npm i -S reflect-metadata @newdash/inject
// tsconfig.json
// remember enable decorator related flags
{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  }
}
// import reflect lib firstly
import "reflect-metadata"; 
import { inject } from "@newdash/inject"

// a really simple example
it('should support deep constructor injection', async () => {

  class A {
    v: number
    constructor(@inject("v") v) {
      this.v = v;
    }
  }

  class B {
    a: InjectWrappedInstance<A>
    constructor(@inject(A) a) {
      this.a = a;
    }
  }

  const ic = InjectContainer.New();
  ic.registerInstance("v", 999); // define an instance provider in simple way
  const b = await ic.getInstance(B);
  expect(b.a.v).toBe(999);

});

CHANGELOG

LICENSE

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.2.31 (2022-04-04)

0.2.30 (2021-12-17)

0.2.29 (2021-06-18)

0.2.28 (2021-06-07)

Features

0.2.27 (2020-11-05)

Bug Fixes

0.2.26 (2020-11-05)

0.2.25 (2020-11-04)

Bug Fixes

0.2.24 (2020-11-03)

0.2.23 (2020-11-03)

Features

Bug Fixes

0.2.22 (2020-10-08)

Features

  • reverse createWrapper, add 'casecade' wrapper (8bde3fc)

Bug Fixes

0.2.21 (2020-10-08)

Features

  • #8, make sure all method run with latest container (3a2843b)

0.2.20 (2020-10-08)

Features

0.2.19 (2020-09-17)

Features

0.2.18 (2020-09-07)

Bug Fixes

  • provide functino not work with @noWrap (afdba8a)

0.2.17 (2020-09-01)

Bug Fixes

0.2.16 (2020-09-01)

Bug Fixes

0.2.15 (2020-08-31)

0.2.14 (2020-08-28)

Bug Fixes

0.2.13 (2020-08-28)

Features

0.2.12 (2020-08-27)

Features

0.2.11 (2020-08-26)

Features

0.2.10 (2020-08-25)

0.2.9 (2020-08-25)

Bug Fixes

0.2.8 (2020-08-25)

Features

Bug Fixes

0.2.7 (2020-08-24)

Features

0.2.6 (2020-08-24)

0.2.5 (2020-08-21)

Features

  • logger: update (0e704ba)
  • support deep constructor injection (8051aae)

Bug Fixes

0.2.4 (2020-08-21)

0.2.3 (2020-08-20)

Features

  • disable wrapper in property deep injection (02da137)

0.2.2 (2020-08-20)

Features

  • support register multi providers (5ea8066)

0.0.14 (2020-08-20)

0.0.13 (2020-08-20)

0.0.12 (2020-08-19)

Features

  • types refactor & static method inject (dbccf0a)

0.0.11 (2020-08-19)

0.0.10 (2020-08-19)

0.0.9 (2020-08-19)

Features

  • support disable wrapper for type (6aa6cc1)

0.0.8 (2020-08-19)

Bug Fixes

  • wrapper for constructor (5f3a2fe)

0.0.6 (2020-08-19)

Bug Fixes

0.0.5 (2020-08-19)

Features

0.0.4 (2020-08-18)

0.0.3 (2020-08-18)

0.0.2 (2020-08-18)

Features

  • move v1 from odata v4 server (301b4ea)