This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Computed Promises', | |
_foobar: Ember.on('init', function() { | |
Promise.resolve(2) | |
.then(value => { | |
let result = value + 1; | |
this.set('result', result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
firstName: null, | |
lastName: null, | |
logs: [], | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
let _myComputedProperty = Ember.computed('foobar', function() { | |
let foobar = this.get('foobar'); | |
console.log('myComputedProperty triggered >', foobar); | |
return '_' + foobar + '_'; | |
}); | |
export default Ember.Controller.extend({ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['child-c'], | |
classNameBindings: ['dashed'], | |
dashed: false, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
hash: {a: 1, b: 2}, | |
hashComputed: Ember.computed('hash', function() { | |
console.log('hashComputed triggered'); | |
return JSON.stringify(this.get('hash')); | |
}), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
function emberFruit(name, price, color) { | |
let fruit = { | |
name: name, | |
price: price, | |
attrs: {color: color} | |
}; | |
return Ember.Object.create(fruit); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
function buildWithAlias(item) { | |
// add the alias when the item is being created, | |
// this might also be done inside an Ember Data model | |
let foo = { | |
nephew: Ember.computed.alias('parent.child.nephew') | |
}; | |
item = Object.assign(item, foo); | |
return Ember.Object.create(item); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['dialogue-body'] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
obj: {}, | |
fi: Ember.computed('obj.fi', function() { | |
return this.get('obj.fi'); | |
}), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
let FooBar = Ember.Component.extend({ | |
}); | |
FooBar.reopenClass({ | |
positionalParams: ['p1', 'p2'] | |
}); | |
export default FooBar; |