- s/Ember.select/Ember.Select i think.
This slide is damn funny ^_^
Nothing to add to the slide, but a minor note to keep in mind: there is another
difference. arrayComputed
adds observers to keep refs up to date. So eg
var array = obj.get('someArrayComputedProperty');
// later modify dependency
// array is kept up to date
It would be nice to not have to do this: would like to make the reduceComputed
stuff support lazy, but it's not there yet.
-
callbacks get given
changeMeta
with many useful properties, likeindex
of item that changed -
callbacks also given
instanceMeta
, a scratchpad that is 〈instance, property〉 specific where you can keep track of things for more involved properties. For example,intersect
keeps track of a count of items seen per dependent array to know when an item belongs in the intersection and when it does not. -
It is possible to depend on properties of items in arrays. This will still give callbacks the right index. This is actually non-trivial when you think about it (it's also not as performant as doing non-property stuff, all other things equal).
-
This feature is actively worked on: check release notes. Some newer stuff is still experimental and behind feature flags, but for instance you can depend on multiple item properties with a brace syntax, as in
// depends on feature propertyBraceExpansion Ember.Object.extend({ items: [{ propA: 'a', propB: 'b', propC: 'c'}, { propA: 'a2', propB: 'b2', propC: 'c2' }], // if you change either `propA` on something in `items`, or `propB`, but not // `propC`, the item will be removed and readded to `computed`. When it is // removed you will be passed the previous value. computed: Ember.reduceComputed('items.@each.{propA,propB}', { addedItem: addedItemCallback, removedItem: removedItemCallback }); })
-
maybe give a shout-out to ember-cpm, a great place to contribute macros.
-
also a shout-out to ember-enumerology which is awesome in its own right and has been upgraded to use reduce computeds.