You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was very surprised when I found out today that in the computed object, the dependencies for each computed property are identified by the names of the parameters passed into the respective functions. This seems to be at odds with what I thought was a common principle in JS, namely that I can call my parameters whatever I want in the function head and worry about what is passed in elsewhere. I guess another problem with the current design of computed is that you can't dynamically determine the dependencies of a property.
May I ask what the rationale behind this is? I believe a more intuitive approach would be to specify dependencies in the form of a list of (string) keys, similar to how component.observe works for example.
The text was updated successfully, but these errors were encountered:
Having the computed property dependencies be fixed makes them able to be analyzed at compile time, so that Svelte can output code to recompute only the computed properties that might have changed. As for the syntax, it is a bit magical, but provides a very succinct way of declaratively specifying these dependencies.
If you have a problem that is more general than computed properties can solve, a reasonable solution would probably be to just attach some .observe handlers to the component in its oncreate hook.
Hi,
I was very surprised when I found out today that in the
computed
object, the dependencies for each computed property are identified by the names of the parameters passed into the respective functions. This seems to be at odds with what I thought was a common principle in JS, namely that I can call my parameters whatever I want in the function head and worry about what is passed in elsewhere. I guess another problem with the current design ofcomputed
is that you can't dynamically determine the dependencies of a property.May I ask what the rationale behind this is? I believe a more intuitive approach would be to specify dependencies in the form of a list of (string) keys, similar to how
component.observe
works for example.The text was updated successfully, but these errors were encountered: