static-injector 5.0.0-alpha.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/readme.md +15 -15
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -21,27 +21,24 @@
|
|
|
21
21
|
|
|
22
22
|
- Create a first level dependency injector with `Injector.create`
|
|
23
23
|
```ts
|
|
24
|
-
import { Injector } from 'static-injector';
|
|
24
|
+
import { Injector, inject } from 'static-injector';
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
class Main {
|
|
27
|
+
child = inject(Child);
|
|
28
|
+
}
|
|
29
|
+
class Child {
|
|
30
|
+
output() {
|
|
31
|
+
return 'hello world';
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
let instance = injector.get(FirstClass);
|
|
37
|
-
console.log(instance.hello());
|
|
38
|
-
|
|
34
|
+
let injector = Injector.create({ providers: [Main, Child] });
|
|
35
|
+
const instance = injector.get(Main);
|
|
36
|
+
console.log(instance.child.output());
|
|
39
37
|
```
|
|
40
38
|
|
|
41
39
|
# Different from `injection-js`
|
|
42
40
|
|
|
43
|
-
- `injection-js` belongs to dynamic dependency injection and is a version used before Angular5.
|
|
44
|
-
- In theory, it would be faster than `injection-js` (otherwise Angular wouldn't do the replacement...), but there was no benchmark done
|
|
41
|
+
- `injection-js` belongs to dynamic dependency injection and is a version used before Angular5. Currently no longer updated
|
|
45
42
|
- The two are basically interchangeable (the details need to be adjusted)
|
|
46
43
|
|
|
47
44
|
- Support the use of `inject` during construction
|
|
@@ -58,4 +55,7 @@ console.log(instance.hello());
|
|
|
58
55
|
|
|
59
56
|
# Sync
|
|
60
57
|
|
|
61
|
-
- Currently, the synchronization logic has been refactored and modified using `@code
|
|
58
|
+
- Currently, the synchronization logic has been refactored and modified using `@code-recycle/cli` to ensure consistency with the official version of `angular`
|
|
59
|
+
|
|
60
|
+
# Examples
|
|
61
|
+
- [https://github.com/wszgrcy/static-injector/tree/main/test/import](https://github.com/wszgrcy/static-injector/tree/main/test/import)
|