Howdy Embereños!
This PR brings Composable Computed Properties to live. What is CCP? Well, it is a computed property that combines other computed properties
Example:
var sort = Ember.computed.sort,
union = Ember.computed.union,
equal = Ember.computed.equal,
mapBy = Ember.computed.mapBy,
not = Ember.computed.not,
compare = Ember.compare,
and = Ember.computed.and;
// Example 1
var Person = Ember.Object.extend(
napTime: and(
equal('state', 'sleepy'),
not('thirsty'),
not('hungry')
)
);
var person = Person.create({
state: 'sleepy',
thirsty: true,
hungry: false
});
person.get('napTime') => false
person.set('thirsty', false)
person.get('napTime') => true
// Example 2
var Kitties = Ember.Object.extend(
allKitties: sort(
union(
mapBy('whiteKitties', 'name'),
mapBy('blackKitties', 'name')
), compare
)
);
var kitties = Kitties.create({
whiteKitties: Ember.A([
{ name: 'whiskeys' },
{ name: 'bagels' }
]),
blackKitties: Ember.A([
{ name: 'little boots' }
]),
});
kitties.get('allKitties') => ['bagels', 'little boots', 'whiskeys']
Let me know what you guys think.
I heard some people complain that examples are hard to read. I’m open to any suggestions on improving it