@art-ws/di 2.0.18 → 2.0.19
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/dist/es/injector.d.ts +2 -0
- package/dist/es/injector.js +9 -1
- package/package.json +1 -1
package/dist/es/injector.d.ts
CHANGED
package/dist/es/injector.js
CHANGED
@@ -112,7 +112,7 @@ export class Injector {
|
|
112
112
|
async runScope(fn, options) {
|
113
113
|
const injector = new Injector();
|
114
114
|
injector.parent = this;
|
115
|
-
injector.addProviders(...(options?.providers || []));
|
115
|
+
injector.addProviders({ token: Injector, factory: () => injector }, ...(options?.providers || []));
|
116
116
|
Injector.onScope?.({ injector });
|
117
117
|
return asyncLocalStorage.run({ injector }, async () => {
|
118
118
|
try {
|
@@ -123,6 +123,14 @@ export class Injector {
|
|
123
123
|
}
|
124
124
|
});
|
125
125
|
}
|
126
|
+
dispose() {
|
127
|
+
this.parent = null;
|
128
|
+
this.#instances.clear();
|
129
|
+
this.#factories.clear();
|
130
|
+
}
|
131
|
+
getInstances() {
|
132
|
+
return Array.from(this.#instances.values());
|
133
|
+
}
|
126
134
|
}
|
127
135
|
export function inject(token) {
|
128
136
|
const asyncContext = asyncLocalStorage.getStore();
|