Never Pummel Muskoxen

    @booster-ts/core
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.1 • Public • Published

    Booster-ts Core

    Core DI Library

    Installation

    You can get the latest release and the type definitions using npm:

    $ npm install @booster-ts/core reflect-metadata --save
    

    /!\ @booster-ts/core requires TypeScript >= 2.0, your tsconfig should look similar to the one below (experimentalDecorators, emitDecoratorMetadata are important)

    {
        "compilerOptions": {
            "target": "es5",
            "lib": ["es6"],
            "types": ["reflect-metadata"],
            "module": "commonjs",
            "moduleResolution": "node",
            "experimentalDecorators": true,
            "emitDecoratorMetadata": true
        }
    }

    Getting Started

    You can declare dependencies with @booster() decorator.

    import { booster } from '@booster-ts/core';
    
    @booster()
    export class DependencyA {
        public data: number = 0;
    }

    You can then require this dependency.

    import { booster } from '@booster-ts/core';
    import { DependencyA } from "./dependencyA";
    
    @booster()
    export class DependencyD {
    
        constructor(public a: DependencyA   ) { }
    
        public update() {
            this.a.data++;
        }
    }

    @booster-ts/core will resolve the dependencies needed for you

    import { Injector } from '@booster-ts/core';
    
    const injector = new Injector();
    const dep: DependencyD = injector.inject(DependencyD);
    
    dep.update();

    Install

    npm i @booster-ts/core

    DownloadsWeekly Downloads

    11

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    22.3 kB

    Total Files

    9

    Last publish

    Collaborators

    • imoverlord