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

and helper should short-circuit #58

Closed
jrforrest opened this issue Jul 5, 2017 · 2 comments
Closed

and helper should short-circuit #58

jrforrest opened this issue Jul 5, 2017 · 2 comments

Comments

@jrforrest
Copy link

jrforrest commented Jul 5, 2017

It seems like the and helper should short circuit, so using methods or computed props as the arguments does not cause the rightmost expressions to be evaluated if the left evaluates to false. This behavior would be more consistent with how JS works.

This came up in our application due to evaluation of computed properties on one of our models causing unnecessary network fetches. We hoped to prevent these with short-circuiting logic but were surprised to find that even when the first expression evaluated to false the second was still called.

We reproduced this behavior in the twiddle below.

Twiddle: https://ember-twiddle.com/cc9681fd51fe0c2505ac62781dbd41a0?openFiles=templates.application.hbs%2C

@Turbo87
Copy link
Contributor

Turbo87 commented Aug 2, 2017

@jrforrest due to the way helpers work in Ember this is simply not possible. helpers are essentially just functions and any parameter that you pass into a function needs to be evaluated before being able to call the function, and the same is true for helpers in Ember.

@rwjblue rwjblue closed this as completed Aug 2, 2017
@rwjblue
Copy link
Collaborator

rwjblue commented Aug 2, 2017

Thanks for explaining @Turbo87

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

3 participants