1.3.3 • Published 3 years ago

@chyan/ioc v1.3.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Dependency Injection

Dependency injection library for Typescript.

Small And Easier To Use.

Quick Start

import { Injectable, MainApplication, ioc, AutoWired } from "@chyan/ioc";
@Injectable()
class Service1 {
  log() {
    console.log("service 1");
  }
}

@Injectable()
class Service2 {
  log() {
    console.log("service 2");
  }
}

@MainApplication()
class Application {
  @AutoWired()
  s1!: Service1;

  constructor(private s2: Service2) {}

  log() {
    console.log(this.s1 === ioc.fetchInjectorViaClass(Service1)); // true
    console.log(this.s2 === ioc.fetchInjectorViaClass(Service2)); // true
    this.s1.log(); // service 1
    this.s2.log(); // service 2
  }
  main() {
    this.log();
  }
}

MainApplication will auto invoke main method

1.3.3

3 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago