You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: handle correctly non-shared instances in injector
Currently `$injector` can have non-shared instances by setting the third argument of the `register` method to false, i.e.:
```
$injector.register("myClass", MyClass, false);
```
However, in this case, the injector caches only the last created instance and this way it will not call the dispose method of all created instances. Fix this by caching all instances in an array and iterrate over them when disposing them.
This way we can have correct resolving of instances by name when constructor has non-injectable dependencies:
```
class A {
constructor(private stringArg: string) { }
}
$injector.register("a", A, false);
// in another file:
$injector.resolve("a", { stringArg: "stringValue" }); //returns new instance;
$injector.resolve("a", { stringArg: "different stringValue" }); //returns new instance;
```
0 commit comments