dependency-injection-v1
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

dependency-injection-v1

dependency-injection-v1 is a JS/TS library for dealing with Dependency Injection.

Installation

Use the package manager npm to install dependency-injection-v1.

npm install dependency-injection-v1

Usage

import { Injectable, Inject } from 'dependency-injection-v1';

@Injectable
class A {
  public getUser() {
    return {
      username: 'lekato',
      message: 'easy but good',
    };
  }
}

class B {
  @Inject(A) propertyA: A;

  public showUserMessage() {
    const user = this.propertyA.getUser();
    console.log(`${user.username} said: ${user.message}`);
  }
}

const b = new B();
b.showUserMessage();

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Package Sidebar

Install

npm i dependency-injection-v1

Weekly Downloads

1

Version

1.0.6

License

MIT

Unpacked Size

4.83 kB

Total Files

8

Last publish

Collaborators

  • lekato