Skip to content

Commit f16fe40

Browse files
committed
scoped container creates new instance for first time only (fixes #61)
1 parent 89bdaa4 commit f16fe40

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ContainerInstance.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ export class ContainerInstance {
105105
if (service && this !== globalContainer) {
106106
const clonedService = Object.assign({}, service);
107107
clonedService.value = undefined;
108-
return this.getServiceValue(identifier, clonedService);
108+
const value = this.getServiceValue(identifier, clonedService);
109+
this.set(identifier, value);
110+
return value;
109111
}
110112

111113
return this.getServiceValue(identifier, service);
@@ -151,6 +153,11 @@ export class ContainerInstance {
151153
*/
152154
set(token: Token<any>, value: any): this;
153155

156+
/**
157+
* Sets a value for the given type or service name in the container.
158+
*/
159+
set(token: ServiceIdentifier, value: any): this;
160+
154161
/**
155162
* Sets a value for the given type or service name in the container.
156163
*/

0 commit comments

Comments
 (0)