Socket
Socket
Sign inDemoInstall

@tuxjs/core

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tuxjs/core

Inversion of control container for JavaScript, Typescript


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
26.8 kB
Created
Weekly downloads
 

Readme

Source

@tuxjs/core · Inversion of control container for JavaScript, Typescript

A powerful and lightweight inversion of control container for JavaScript powered by TypeScript.

How to install @tuxjs/core


npm install @tuxjs/core

npm install @tuxjs/core --save-dev

npm install reflect-metadata

Guide use @tuxjs/core


import { inject, injectable, Container } from '@tuxjs/core';
import 'reflect-metadata';

export interface Animal {
    _name: string;
    getName(): string;
}

@injectable()
export class Dog implements Animal {
    _name: string;

    constructor() {
        this._name = "Wofl";
    }

    getName(): string {
        return this._name;
    }

}

@injectable()
export class Meow implements Animal {
    _name: string;

    constructor() {
        this._name = "Meow";
    }

    getName(): string {
        return this._name;
    }

}

@injectable()
export class CollectionPet {

    private _dog: Dog;
    private _meow: Meow;

    constructor(
        @inject(Dog) dog: Dog,
        @inject(Meow) meow: Meow
    ) {
        this._dog = dog;
        this._meow = meow;
    }

    getDogName() {
        return this._dog.getName();
    }

    getMeowName() {
        return this._meow.getName();
    }
}

let collectionPet = Container.resolve(CollectionPet);

console.log(collectionPet.getDogName());
console.log(collectionPet.getMeowName());


Thanks, click on the star button above to support me

Repository Tux-Core click here

Keywords

FAQs

Last updated on 19 Jul 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc