@amazon/vinyl-di 1.1.0 → 1.1.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.
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @amazon/vinyl-di
|
|
2
|
+
|
|
3
|
+
[](https://amazonmusic.github.io/vinyl)
|
|
4
|
+
[](https://www.npmjs.com/package/@amazon/vinyl-di)
|
|
5
|
+
[](https://bundlejs.com/?q=@amazon/vinyl-di)
|
|
6
|
+
|
|
7
|
+
Constructor-based dependency injection with a compile-time-checked dependency
|
|
8
|
+
graph. Used internally by Amazon Vinyl, but standalone.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```shell
|
|
13
|
+
npm install @amazon/vinyl-di
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Dependency Injection
|
|
2
17
|
|
|
3
18
|
Amazon Vinyl uses the most common form of dependency injection; requesting
|
|
4
19
|
dependencies through constructors.
|
|
@@ -29,7 +44,7 @@ const requester = new Requester({
|
|
|
29
44
|
})
|
|
30
45
|
```
|
|
31
46
|
|
|
32
|
-
There are two steps to dependency injection
|
|
47
|
+
There are two steps to dependency injection: creating a record of dependency
|
|
33
48
|
factories, then creating a container that uses the factories to construct
|
|
34
49
|
implementations.
|
|
35
50
|
|
|
@@ -43,7 +58,7 @@ there are no cyclic dependencies, missing dependencies, or incompatible types.
|
|
|
43
58
|
Example:
|
|
44
59
|
|
|
45
60
|
```typescript
|
|
46
|
-
import { validateFactories } from '@amazon/vinyl-
|
|
61
|
+
import { validateFactories } from '@amazon/vinyl-di'
|
|
47
62
|
|
|
48
63
|
class A {}
|
|
49
64
|
|
|
@@ -73,10 +88,11 @@ const factories = validateFactories({
|
|
|
73
88
|
|
|
74
89
|
These factories will be used to create implementations. Use `createContainer` to
|
|
75
90
|
create a container that may be disposed and provides an object with getters to
|
|
76
|
-
lazily
|
|
91
|
+
lazily construct implementations from the provided factories.
|
|
77
92
|
|
|
78
93
|
```typescript
|
|
79
|
-
import { createContainer
|
|
94
|
+
import { createContainer } from '@amazon/vinyl-di'
|
|
95
|
+
import { createDisposer } from '@amazon/vinyl-util'
|
|
80
96
|
|
|
81
97
|
const { add, dispose } = createDisposer()
|
|
82
98
|
|
|
@@ -98,7 +114,7 @@ import {
|
|
|
98
114
|
externalDependencies,
|
|
99
115
|
validateFactories,
|
|
100
116
|
createContainer,
|
|
101
|
-
} from '@amazon/vinyl-
|
|
117
|
+
} from '@amazon/vinyl-di'
|
|
102
118
|
|
|
103
119
|
// External services managed elsewhere
|
|
104
120
|
const logger = new Logger()
|
|
@@ -127,3 +143,7 @@ container.dispose()
|
|
|
127
143
|
As a general guideline, when defining a dependency to be provided, the interface
|
|
128
144
|
requested should be the minimum API needed, and disposal should be the
|
|
129
145
|
responsibility of the creator.
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amazon/vinyl-di",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Simple dependency injection",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
"watch:release": "tsx buildSrc/build.ts --watch --release"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@amazon/vinyl-build-utils": "^1.1.
|
|
73
|
-
"@amazon/vinyl-jasmine-wrapper": "^1.1.
|
|
72
|
+
"@amazon/vinyl-build-utils": "^1.1.1",
|
|
73
|
+
"@amazon/vinyl-jasmine-wrapper": "^1.1.1"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@amazon/vinyl-util": "^1.1.
|
|
76
|
+
"@amazon/vinyl-util": "^1.1.1"
|
|
77
77
|
},
|
|
78
78
|
"browserslist": [
|
|
79
79
|
"defaults, chrome 52, firefox 54, edge 15, safari 8"
|
|
80
80
|
],
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "e5a3429d802564132b16808a5b8a8e15a023a548"
|
|
82
82
|
}
|