Skip to content
This repository was archived by the owner on Apr 21, 2024. It is now read-only.

Commit 965f1b6

Browse files
authored
Merge pull request #11 from Coder-Spirit/self-resolve
Self resolution
2 parents 8ede2d7 + 4dfd823 commit 965f1b6

File tree

7 files changed

+314
-214
lines changed

7 files changed

+314
-214
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ console.print(person.name) // Prints "Timmy"
8080
// We can resolve registered "groups"
8181
container.resolveGroup('group1') // ~ [1, 2], not necessarily in the same order
8282
container.resolveGroup('group2') // ~ [3, 4], not necessarily in the same order
83+
84+
// We can also resolve the container itself, and the return type will always be
85+
// up to date. This is useful if we want to use the container as a factory for
86+
// some of your dependencies.
87+
const resolvedContainer = container.resolve('$')
8388
```
8489

8590
It is also possible to register and resolve asynchronous factories and
@@ -117,6 +122,8 @@ dependencies. If you are curious, just try out:
117122
- Stricter types for dependencies re-registration.
118123
- Groups registration and resolution: very useful when we need to resolve all
119124
dependencies belonging to a same category.
125+
- Self-resolution. The container is able to resolve itself, to be used as a
126+
factory.
120127
- The container interface has been split into `ReaderContainer` and
121128
`WriterContainer`, making it easier to use precise types.
122129
- More extense documentation.

lambda-ioc/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ console.print(person.name) // Prints "Timmy"
8080
// We can resolve registered "groups"
8181
container.resolveGroup('group1') // ~ [1, 2], not necessarily in the same order
8282
container.resolveGroup('group2') // ~ [3, 4], not necessarily in the same order
83+
84+
// We can also resolve the container itself, and the return type will always be
85+
// up to date. This is useful if we want to use the container as a factory for
86+
// some of your dependencies.
87+
const resolvedContainer = container.resolve('$')
8388
```
8489

8590
It is also possible to register and resolve asynchronous factories and
@@ -117,6 +122,8 @@ dependencies. If you are curious, just try out:
117122
- Stricter types for dependencies re-registration.
118123
- Groups registration and resolution: very useful when we need to resolve all
119124
dependencies belonging to a same category.
125+
- Self-resolution. The container is able to resolve itself, to be used as a
126+
factory.
120127
- The container interface has been split into `ReaderContainer` and
121128
`WriterContainer`, making it easier to use precise types.
122129
- More extense documentation.

0 commit comments

Comments
 (0)