File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 55[ ![ License] ( https://img.shields.io/github/license/x-profiler/injection )] ( LICENSE )
66
77An IoC implemention for xprofiler.
8+
9+ ## Usage
10+
11+ ### Decorator
12+
13+ ``` ts
14+ import { Injectable , Inject } from " @xprofiler/injection" ;
15+ import { Config } from " ./config" ;
16+
17+ @Injectable ()
18+ export class Foo {
19+ @Inject ()
20+ private config: Config ;
21+
22+ getKmsConfig(@Inject (' KMS_KEY' ) key : string ) {
23+ return this .config [key ];
24+ }
25+ }
26+ ```
27+
28+ ### Container
29+
30+ ``` ts
31+ import { Container } from " @xprofiler/injection" ;
32+ import { Foo , Bar } from " ./items" ;
33+
34+ const container = new Container ();
35+
36+ container .set (Foo );
37+ container .set (Bar );
38+
39+ const foo = container .get (Foo );
40+ const bar = container .get (Bar );
41+ ```
You can’t perform that action at this time.
0 commit comments