@tobes31415/dependency-injection
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@tobes31415/dependency-injection", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Tiny dependency injection", | ||
@@ -5,0 +5,0 @@ "main": "lib/di.min.js", |
@@ -10,25 +10,19 @@ # DI | ||
# Basic Useage | ||
import { onDispose, dispose } from "@tobes31415/dispose" | ||
onDispose(foo, () => { | ||
//release resources | ||
//disconnect from servers, etc | ||
}); | ||
dispose(foo); | ||
import { DI } from "@tobes31415/dependency-injection"; | ||
import { SomeService } from "./someService"; | ||
class SomeClass { | ||
constructor() { | ||
this.service = DI.resolve(SomeService); | ||
} | ||
} | ||
# Advanced Useage | ||
import { isDisposed, assertNotDisposed, createDisposeableFunctionWrapper, dispose } from "@tobes31415/dispose" | ||
DI.useClass(Potato, Carrot); | ||
const obj = DI.resolve(Potato) // instance of Carrot | ||
if (isDisposed(foo)) { | ||
foo = new Foo(); | ||
} | ||
DI.useObject(Potato, {banana}); | ||
const obj = DI.resolve(Potato) // {banana} | ||
assertNotDisposed(bar); //throws exception if bar has been disposed | ||
const baz = createDisposeableFunctionWrapper( (a,b,c) => a * b + c ); | ||
baz(1,2,3) //outputs 5 | ||
dispose(baz); | ||
baz(1,2,3) // throws an exception | ||
DI.useFactory(Potato, () => 123); | ||
const obj = DI.resolve(Potato) //123 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26830
17
28