Skip to content

tvrcgo/injection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

injection

An IoC toolkit

Usage

Decorate

import { injectable, inject } from '@tvrcgo/injection'

// lib/logger.ts
@injectable('logger')
export class Logger {
  info() {}

  @inject('oss')
  sender
}

// lib/oss.ts
@injectable('oss')
export class OSS {
  put() {}
}

Container

import { Container } from '@tvrcgo/injection'

const container = new Container()
container.load(['dist/lib/**'])

const logger = container.use('logger')
logger.info()
logger.sender.put()

Releases

No releases published

Packages

No packages published