Skip to content

jcbinet/ts-inject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@jcbinet/ts-inject

Basic dependency injection for TypeScript.

Getting Started

Install the package using npm:

npm i @jcbinet/ts-inject

Example

To automatically inject dependency into your classes, you need to mark them with the @Injectable() decorator.

By example, here the WebSocketService, HttpService will be automatically injected into API.

import { Injectable, Injector } from '@jcbinet/ts-inject';

const api = Injector.resolve<API>(API);

@Injectable()
export class API {
  constructor(private http: HttpService,
              private ws: WebSocketService) { }
  
  /** ... */
}

About

Basic dependency injection for TypeScript

Resources

Stars

Watchers

Forks

Packages

No packages published