I was wondering if there is any difference between using a computed property and using a helper from the ember-truth-helpers addon. Computed properties will be cached and only recomputed when needed. Is this also the case for helper values in ember?
I’m currently thinking of using the ember-truth-helpers, but if this means a performance downgrade, I’ll keep using computed properties.
Helper invocations have the same caching characteristics as CP’s, they will only be invalidated (and their ‘compute’ function called) when incoming attrs change. The helpers have the ability to actually have less overhead if a component isn’t needed (since a helper invocation is much lighter than a component).
I personally find the types of helpers that ember-truth-helpers provides to be much more declarative than CP’s.
I personally prefer computed properties. With CPs, if you want to change the condition when XY is displayed etc. you only have to change your JS file and not the templates. Put differently, it encapsulates the logic behind what you’re trying to do in the template. Sure it won’t matter much if it’s just a negation of something but who can say that that won’t change? It will be easier to make the change in one place after that. However, this works best when your CPs reveal the intention of what you’re doing, e.g. displayFoo instead of firstAndLastNameEntered.