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

Support @computedFrom on functions #311

Closed
jsobell opened this issue Feb 6, 2016 · 1 comment
Closed

Support @computedFrom on functions #311

jsobell opened this issue Feb 6, 2016 · 1 comment

Comments

@jsobell
Copy link

jsobell commented Feb 6, 2016

Currently functions do not support computedFrom, but accessors do. In the case where a VM is exposing an internally calculated value, there is currently no proper way to ask Aurelia to include the method in a dirty check, or to indicate which dependencies need monitoring for change tracking.

Accessors are methods, so when we have a method such as FullName we can decorate it because FullName takes no parameters and returns data dependent on two internal variables that the view never sees, so we are hiding the implementation.
However, if we decide to have arrays of firstNames and lastNames, fullName requires a parameter, typically $index from a repeater. There is now no way of using a get accessor, so we have to 'bodge' the system and include firstName[$index] and lastName[$index] in a method call to simulate 'computedFrom' and ensure the method is called if either of those instances is updated, but this also exposes the implementation to the view.

My suggestions is that we support @computedFrom(...vars) on methods, as this retains knowledge of the dependencies in the VM.
What happens when a method is method is non-deterministic? We don't have a means of specifying dirty-checking, so perhaps we need to support a parameterless @computedFrom(), or allow @binding on a method.

@jdanyow
Copy link
Contributor

jdanyow commented Feb 9, 2016

linking to #147 and closing. Will update #147's title to make it easier to find

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

No branches or pull requests

2 participants