Ember.computed.* is your friend!
I recently got turned on to a much more readable method for writing computed properties in Ember with CoffeeScript by way of Alex Speller’s talk at this year’s EmberFest, The mistakes everyone makes with Ember.JS - Avoiding Common Pitfalls. I had previously been writing computed properties like this:
Which works out just fine, but it’s much more readable to take this same idea and turn it into this:
This new method of writing computed properties made me investigate the Ember namespace documentation, which opened my eyes to a ton of shorthand helpers for computed properties. There are tons of great shorthand methods to do simple computed property calculations that you should be utilizing. I highly recommend that you look at the documentation, but here are a few to get you excited.
Greater Than Comparisons
Before:
After:
Logical ‘Or’
Before:
After:
Intersections
Before:
After:
Read the Docs!
Seriously, have a look at the Ember namespace documentation. Only write a custom computed property when you’re doing something really interesting. Otherwise, let the framework do the heavy lifting.