We could, but the point is that we want to be constantly polling, no matter if there's a listener or not. The main thing that the article doesn't say is that in their original example, there is only one Observable (like a Subject - which would also stay in memory as long as the app runs) whereas the solution with an injector creates a new Observable/Signal for each consumer/component. As a result, there's no real caching at play and the point of using a Signal, in that case, is lower (since there will be one signal for each subscriber - instead of one shared resource for all of them).

Also, since there's only one request, I don't get the "memory leak" argument, since there won't be creation of multiple Observables.

Alain Chautard
Alain Chautard

Written by Alain Chautard

Google Developer Expert in Angular, Consultant and Trainer at http://www.angulartraining.com

No responses yet