Skip to content

Commit f3b9838

Browse files
updated examples
1 parent 13a4d24 commit f3b9838

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

examples/javascript/hierarchical-containers.js

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

3+
/*
4+
If a container can't find a value within itself, it will look it up in ascendant containers.
5+
There a 3 ways to set a parent for a container:
6+
*/
7+
38
const grandParentContainer = new Container();
49

10+
// 1.
511
const parentContainer = grandParentContainer.createChild();
612

13+
// 2.
714
const childContainer = new Container();
815
childContainer.setParent(parentContainer);
916

17+
// 3.
1018
const deepNestedContainer = new Container({
1119
parent: childContainer
1220
});

examples/typescript/hierarchical-containers.ts

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

3+
/*
4+
If a container can't find a value within itself, it will look it up in ascendant containers.
5+
There a 3 ways to set a parent for a container:
6+
*/
7+
38
const grandParentContainer = new Container();
49

10+
// 1.
511
const parentContainer = grandParentContainer.createChild();
612

13+
// 2.
714
const childContainer = new Container();
815
childContainer.setParent(parentContainer);
916

17+
// 3.
1018
const deepNestedContainer = new Container({
1119
parent: childContainer
1220
});

0 commit comments

Comments
 (0)