-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Functions should be treated as objects for purposes of updating computations #413
Comments
In that example, isn't On the other hand I guess in this case burdening everyone with an extra |
Ha, that's fair. The place I encountered this was in an app that used D3 scales — rather than generating a new function when the dimensions change, the D3 convention is to call a method of a function that updates the values inside the closure where the function is generated: https://svelte.technology/repl?version=1.13.1&gist=fcdc653576d0ffb156b4d863cd3e5874 If you shrink the width of the output window you'll see that |
recompute computed values with functions as dependencies
This example shows the bug (which I did just encounter in a real application, as bizarre as the example looks) — computed values are recomputed if one or more of their dependencies a) are among the
changed
items AND b) the value has changed from its previous value or is a non-primitive value (since objects and arrays could have been mutated).That doesn't take account of functions, whose return value might be dependent on a closure. So the check needs to be updated:
Current code:
Better code:
The text was updated successfully, but these errors were encountered: