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
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.
@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.
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
The text was updated successfully, but these errors were encountered: