saber-ioc

A simple Injector for ioc

MIT License

Downloads
21
Stars
4
Committers
2
# from npm
npm install @saber2pr/ioc

# from github
git clone https://github.com/Saber2pr/saber-ioc.git

@saber2pr/reflect

Feature

@Injectable()
class Service {
  public getUser() {
    return 'saber!'
  }
}

class Controller {
  public constructor(@Inject('Service') private Service: Service) {}

  // @InjectProp() private Service: Service

  public test() {
    console.log(this.Service.getUser())
  }
}

const app = Injector(Controller)

app.test() // 'saber!'

API

  1. @Injectable(id?) id id

    `` id

  2. @Inject(id) ()

    Interface Inject

  3. @InjectProp(id) ()

  4. @Singleton

  5. @Static

    @Singleton

  6. Injector build

    ``


start

npm install
npm start

npm run build

npm test


develope and test

you should write ts in /src

you should make test in /src/test


Author

saber2pr


License

MIT

Package Rankings
Top 14.66% on Npmjs.org