teys-injector
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

teys-injector

Simple injector syntax for Typescript code. It allows you to set dependency

import { Injectable, Inject } from "teys-injector";

@Injectable()
class Service {
    
    method1(): boolean {
        return false;
    }
}
import { Inject } from "teys-injector";

class OtherClass {
    
    @Inject()
    svc: Service;
    
    method2() {
        return this.svc.method1();
    }
}

You can also register manually values and resolve them

import { Injector } from "teys-injector";

Injector.Register("user", { username: 'default' });
import { Injector } from "teys-injector";

const defaultUser = Injector.Resolve<User>("user");

Not supported yet

  • Injectable constructor parameters

Package Sidebar

Install

npm i teys-injector

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

20.1 kB

Total Files

11

Last publish

Collaborators

  • pteyssedre