Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 860 Bytes

File metadata and controls

49 lines (32 loc) · 860 Bytes

Infuse

No frills Typescript Dependancy injection.

Example usage

    @Inject()
    export class ServiceA {
    }

    @Inject()
    export class ServiceD {

    }

    @Inject()
    export class ServiceC {
        constructor(private ServiceD: ServiceD) {
        }
    }

    @Inject()
    export class ServiceB {
        constructor(private ServiceC: ServiceC) {
        }
    }

    @Inject()
    export class Resolve {
        constructor(private ServiceA: ServiceA, private serviceB: ServiceB) {

        }
    }


    Injector.Current.register<ServiceA>(ServiceA);

    Injector.Current.register<ServiceB>(ServiceB);

    Injector.Current.register<ServiceC>(ServiceC);

    Injector.Current.register<ServiceD>(ServiceD);

    Injector.Current.register<Resolve>(Resolve);

    let resolve = Injector.Current.get<Resolve>(Resolve);