Function Core

  • Type Parameters

    • T extends (new (...any) => any)

    Parameters

    • Optional Class: T
      Optional

    Returns {
        prototype: __type<any>;
        new (...any): __type<T>;
    } & T

    Example

    import { Core, init, injectable, inject, container, kill } from '@biorate/inversion';

    @injectable()
    class One {
    @init() public initialize() {
    console.log('One module initialized');
    }

    @kill() public kill() {
    console.log('One module killed');
    }
    }

    @injectable()
    class Two {
    @init() public initialize() {
    console.log('Two module initialized');
    }
    }

    @injectable()
    class Three {
    @init() public initialize() {
    console.log('Three module initialized');
    }
    }

    class Root extends Core() {
    @inject(One) public one;
    @inject(Two) public two;
    @inject(Three) public three;
    }

    container.bind(One).toSelf();
    container.bind(Two).toSelf();
    container.bind(Three).toSelf();
    container.bind(Root).toSelf();

    const root = container.get(Root);

    root.$run().then(() => {
    console.log(root.one instanceof One); // true
    console.log(root.two instanceof Two); // true
    console.log(root.three instanceof Three); // true
    });

Generated using TypeDoc