This file contains 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'; | |
// A computed property chain of property(fullName) <- computed(firstName) <- computed(greeting) will | |
// always recalculate computed(firstName) and computed(greeting) when property(fullName) changes. | |
// This means that computed(greeting) will be recalculated even when computed(firstName) didn't change | |
// as a result of property(fullName)'s change. If you find yourself stuck in an "unnecessary expensive | |
// updates" situation, here is something you can do to optimize: | |
export default Ember.Controller.extend({ | |
appName: 'Optimizing computed property recalculation', | |
This file contains 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', | |
fullName: '', | |
firstName: Ember.computed('fullName', function() { | |
return this.get('fullName').split(' ')[0]; | |
}), |
This file contains 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', | |
array: ['a', 'b', 'c'], | |
lengthBased: Ember.computed('array.length', function() { | |
return this.get('array').join(" "); | |
}), | |
This file contains 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'; | |
const {computed} = Ember; | |
const ListPropertiesComponent = Ember.Component.extend({ | |
object: computed.readOnly('params.firstObject'), | |
properties: computed('params.[]', { | |
get() { | |
let [,...props] = this.get('params'); | |
return props; |
This file contains 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' | |
}); |
This file contains 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
trait Generator[+T] { | |
self => | |
def generate: T | |
def map[S](f: T => S): Generator[S] = new Generator[S] { | |
def generate = f(self.generate) | |
} | |
def flatMap[S](f: T => Generator[S]): Generator[S] = new Generator[S] { |