Skip to content

Commit 21d8667

Browse files
#76 Added ES6+ examples, Updated docs
1 parent 6311b88 commit 21d8667

File tree

4 files changed

+28
-34
lines changed

4 files changed

+28
-34
lines changed

examples/use-factory-with-injections.ts renamed to examples/javascript/use-factory-with-injections.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { Container, Injectable, Inject } from 'container-ioc';
1+
import { Container, Injectable } from 'container-ioc';
22

33
const container = new Container();
44

5-
interface IService {
6-
[key: string]: any;
7-
}
8-
9-
@Injectable()
5+
@Injectable(['IUserFactory'])
106
class App {
11-
constructor(@Inject('IUseFactory') private service: IService) {}
7+
constructor(service) {
8+
this.service = service;
9+
}
1210
}
1311

1412
@Injectable()
@@ -19,7 +17,7 @@ container.register([
1917
{ token: 'IService', useClass: Service },
2018
{
2119
token: 'IUseFactory',
22-
useFactory: (service: IService) => {
20+
useFactory: (service) => {
2321
return service;
2422
},
2523
inject: ['IService']
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { Container, Injectable, Inject } from 'container-ioc';
1+
import { Container, Injectable } from 'container-ioc';
22

33
const container = new Container();
44

5-
interface IService {
6-
[key: string]: any;
7-
}
8-
9-
@Injectable()
5+
@Injectable(['IUseFactory'])
106
class App {
11-
constructor(@Inject('IUseFactory') private service: IService) {}
7+
constructor(service) {
8+
this.service = service;
9+
}
1210
}
1311

1412
@Injectable()

examples/javascript/use-value.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Container, Injectable } from 'container-ioc';
2+
3+
const container = new Container();
4+
5+
@Injectable()
6+
class App {
7+
constructor(service) {
8+
this.service = service;
9+
}
10+
}
11+
12+
container.register([
13+
App,
14+
{ token: 'IService', useValue: {}}
15+
]);
16+
17+
const app = container.resolve(App);

examples/use-value.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)