@travetto/di
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -22,3 +22,3 @@ { | ||
}, | ||
"version": "0.0.5" | ||
"version": "0.0.6" | ||
} |
@@ -20,2 +20,4 @@ import { Dependency, InjectableConfig, ClassTarget } from '../types'; | ||
private instances = new Map<TargetId, Map<string, any>>(); | ||
private instancePromises = new Map<TargetId, Map<string, Promise<any>>>(); | ||
private aliases = new Map<TargetId, Map<string, string>>(); | ||
@@ -119,3 +121,2 @@ private targets = new Map<ClassId, Map<string, TargetId>>(); | ||
private async createInstance<T>(target: ClassTarget<T>, name: string = DEFAULT_INSTANCE) { | ||
let instance = await this.construct(target, name); | ||
let targetId = target.__id; | ||
@@ -125,4 +126,14 @@ | ||
this.instances.set(targetId, new Map()); | ||
this.instancePromises.set(targetId, new Map()); | ||
} | ||
if (this.instancePromises.get(targetId)!.has(name)) { | ||
return this.instancePromises.get(targetId)!.get(name); | ||
} | ||
let instancePromise = this.construct(target, name); | ||
this.instancePromises.get(targetId)!.set(name, instancePromise); | ||
let instance = await instancePromise; | ||
if (AppEnv.watch) { | ||
@@ -288,2 +299,3 @@ if (!this.proxies.has(targetId)) { | ||
this.instances.get(targetId)!.delete(config); | ||
this.instancePromises.get(targetId)!.delete(config); | ||
console.debug('On uninstall', cls.__id, config, targetId, handler); | ||
@@ -299,2 +311,3 @@ this.targets.get(cls.__id)!.delete(config); | ||
this.instances.clear(); | ||
this.instancePromises.clear(); | ||
this.proxies.clear(); | ||
@@ -301,0 +314,0 @@ this.proxyHandlers.clear(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19086
522