Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 499 Bytes

README.md

File metadata and controls

38 lines (28 loc) · 499 Bytes

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()