-
I got into a situation when I need to "invalidate" an already registered SINGLETON provider. In other words, I am looking for a way to replace a SINGLETON provider with a new instance. Is it possible? How can I achieve it? If I use sth like this:
@Romakita if you dont mind... ;) |
Beta Was this translation helpful? Give feedback.
Answered by
Romakita
Aug 8, 2022
Replies: 1 comment 2 replies
-
In this case, don’t use ˋInject` decorator. Use injectorService directly to rebuild the service. @Service()
export class Service1 {
@Inject()
protected injector: InjectorService;
protected something: Something;
$onInit() {
this.something = this.injector.invoke(Something);
}
doThis() {
if (new) {
this.something = this.injector.invoke(Something, undefined, { rebuild: true });
}
}
}
see you |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
alexdonh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this case, don’t use ˋInject` decorator. Use injectorService directly to rebuild the service.
see you
Romain