New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signals enable me to implement my own ARC (Active Reference Counting) #53417
Comments
Correct. Observing the act of subscribing / unsubscribing would make the signal read side-effectfull introducing the notion similar to "hot" vs. "cold" observables. This is not what signals are designed for. You might want to use a different reactive primitive for your use-cases. |
I was just trying to avoid it cause for me it means I have to have a Subject and then on top of that for each component I have to cast it into a signal, its at least 2N for memory or even MN. I guess I have then no choice. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are relevant/related to the feature request?
No response
Description
Imagine that I have a global store like NgRx but where each key links to a Singal containing the state of the object. That store is global and multiple components can use the same object - you can imagine it like its firebase.
Now what I want is able to track how many components use the object, when the count go to 0 I want to wait a specific amount of time before GC-ing the signal, or I'll wait that the memory pressure of the hole app exceeds a specific limit cause of multiple reasons e.g. I have to destory the subscription between client and the server which is expensive while the user can need in the next few seconds the same object again.
I have already implemented the solution however I'm not able to implement it with Signals. I'm not capable to implement this with Signals cause you are not allowing me to overwrite the functions or letting me see the counter.
Proposed solution
Enable me to track how many times a singal is subscribed and unsubscribed - I know this is not the right terminology but I think the point which I want to do is clear.
Alternatives considered
None.
The text was updated successfully, but these errors were encountered: