You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+70-5Lines changed: 70 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,17 +10,30 @@
10
10
11
11
## Introduction
12
12
An IOC (Inversion of Control) container for Typescript.
13
+
13
14
The idea behind is to create a simple container that can be used to register and resolve dependencies working with classes & functions but without reflect metadata.
15
+
14
16
It is using simple Typescript code, so it can be used in any project without any dependency.
15
-
Works in NextJS middleware and edge runtime.
17
+
18
+
Works also in NextJS middleware and node+edge runtimes.
16
19
17
20
## Installation
18
21
```npm i @evyweb/ioctopus```
19
22
20
23
## How to use
21
24
22
-
### List your injection tokens
23
-
Create a symbol for each dependency you want to register. It will be used to identify the dependency.
25
+
To use the container, you need to create a container and bind your dependencies.
26
+
To do so you need to create an id for each dependency you want to register.
27
+
28
+
This id that we call an "injection token" can be a string or a symbol.
29
+
(Please note that you have to be consistent and use always strings for binding and resolving dependencies or always symbols, you can't mix them).
30
+
31
+
Then you can bind the dependency to a value, a function, a class, a factory, a higher order function, or a curried function.
32
+
33
+
### Using symbols as injection tokens
34
+
(You can skip "step a" if you prefer to use strings as injection tokens).
35
+
36
+
a) Create a symbol for each dependency you want to register. It will be used to identify the dependency.
0 commit comments