-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Idea: introduce abstraction for computeds with arguments #184
Comments
Woah, it's funny how you opened this issue 5 hours ago and my coworker and I were trying to figure out how we'd solve this very issue 10 hours ago 🤓 |
Does |
Good point, yes I think so. Didn't think it that far through :)
…On Fri, Mar 22, 2019 at 9:25 AM urugator ***@***.***> wrote:
Does "never" pass keepAlive: true to the underlying computed ? I think it
would make sense? Then maybe computed API could be preserved (without
number support)... and perhaps the user should be able to provide other
options like equals...?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#184 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhGYmmc7t9wTI-mLBGqLblzXUIz7Hks5vZJOFgaJpZM4bzk8I>
.
|
For one-object-argument functions (a User object instead of just the userId in your example) a WeakMap could help automatically cleaning up entries with the argument-object being GCed. It would be like an "extension" to the User indirectly holding a computed member for all his todos without depending on them. |
Released as 5.4.0! |
See mobxjs/mobx#1388 (comment) and mobxjs/mobx#1388 (comment). This could potentially replace
createTransformer
as well.Signature:
memoizedComputed<T>(expression: T, invalidationStrategy?: "auto" | "never" | number = "auto"): T
strategies:
"auto"
: remove entries from the memoization table as soon as they becomeunobserved
"never"
: we don't care, cache forever (that is, until the computeds and all things they depend on are GC-ed)number
: remove entries after they have not been hit a the specified amount of time. Probably not needed in a first versoin.Example:
The text was updated successfully, but these errors were encountered: