tsyringe
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -23,2 +23,3 @@ "use strict"; | ||
return function (target) { | ||
injectable()(target); | ||
dependency_container_1.instance.registerSingleton(target); | ||
@@ -25,0 +26,0 @@ }; |
{ | ||
"name": "tsyringe", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Lightweight dependency injection container for JavaScript/TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -13,2 +13,3 @@ [![Travis](https://img.shields.io/travis/Microsoft/tsyringe.svg)](https://travis-ci.org/Microsoft/tsyringe/) | ||
* [injectable()](#injectable) | ||
* [singleton()](@singleton) | ||
* [autoInjectable()](#autoinjectable) | ||
@@ -57,2 +58,23 @@ * [inject()](#inject) | ||
### singleton() | ||
Class decorator factory that registers the class as a singleton within the | ||
global container. | ||
#### Usage | ||
```TypeScript | ||
import {decorators} from "tsyringe"; | ||
const {singleton} = decorators; | ||
@singleton() | ||
class Foo { | ||
constructor() {} | ||
} | ||
// some other file | ||
import {container} from "tsyringe"; | ||
import {Foo} from "./foo"; | ||
const instance = container.resolve(Foo); | ||
``` | ||
### autoInjectable() | ||
@@ -59,0 +81,0 @@ Class decorator factory that replaces the decorated class' constructor with |
22816
335
206