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

MobxPromise can't be killed #6

Open
alisman opened this issue May 18, 2018 · 0 comments
Open

MobxPromise can't be killed #6

alisman opened this issue May 18, 2018 · 0 comments

Comments

@alisman
Copy link
Collaborator

alisman commented May 18, 2018

Hi @adufilie we've run into and issue where, once an mobxpromise has been invoked, it will invoke forever whenever it's observables change, even if no views are observing it. I think this is expected mobx behavior, though not desirable. There needs to be a way to dispose a mobxpromise or at least disable it when there are no real observers. One solution I tried was, in the getter for lastinvokeId, we can detect the count of observers of the result property. Because of @cached, it will always be at least 1. If it's only 1, we could potentially NOT run invoke. The problem then is that we need to run invoke when the result property is referenced again (provided that observed values have changed). When I disabled invoke (when observer count ==1) the promise would never invoke again. Any thoughts?
The use case is, user leaves a tab, the mobxpromises of that serve that tab should not perpetually invoke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant