Skip to content
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

Consider keep-alive mechanisms to extend ownership duration #70

Open
raquo opened this issue Feb 26, 2021 · 0 comments
Open

Consider keep-alive mechanisms to extend ownership duration #70

raquo opened this issue Feb 26, 2021 · 0 comments
Labels
design need to find time https://falseknees.com/297.html

Comments

@raquo
Copy link
Owner

raquo commented Feb 26, 2021

Observable completion (#23) issue talks about killing subscriptions from the stream / producer side, usually to terminate the subscription early, such as the take / takeWhile operator (#33).

On the other hand, sometimes we actually want to extend the duration of the subscription for longer than the owner would normally allow. For example, in Laminar, element owners kill their subscriptions on unmount. So if you make an Ajax request and unmount the component before the response comes in, and nothing else listens to the response, the response will be ignored. Usually this is desired, but if the response observer has a side effect that you want to run regardless of the element's mount status, that side effect won't run.

To mitigate this we could mark this observer with something like keepAlive(maxEvents = 1, timeoutMs = 30000), meaning that any subscription created from it will not terminate immediately but will remain active for a maximum of one incombing event or a maximum of 30 seconds after the owner killed it, whichever comes first.

However, I'm not 100% sure if this is a good idea, because I think maybe the real solution is to use an observer owned by a global owner rather than by an element in such cases. Currently it's not really an option because the global owner would then accumulate many subscriptions from now-unmounted components over time, but maybe if we implement observable completion, we would be able to solve this (e.g. an ajax response stream would complete after emitting the result and any subscriptions listening to it would be killed since no new updates are expected).

Just some thoughts to get this out of my head.

@raquo raquo added the design label Feb 26, 2021
@raquo raquo added the need to find time https://falseknees.com/297.html label Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design need to find time https://falseknees.com/297.html
Projects
None yet
Development

No branches or pull requests

1 participant