Skip to content

Instantly share code, notes, and snippets.

@nkgm
nkgm / controllers.application.js
Last active April 15, 2018 17:49 — forked from bendemboski/controllers.application.js
Optimizing computed property recalculation
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',
@nkgm
nkgm / controllers.application.js
Last active April 15, 2018 15:24 — forked from ofersadgat/controllers.application.js
Computed Update Count
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
fullName: '',
firstName: Ember.computed('fullName', function() {
return this.get('fullName').split(' ')[0];
}),
@nkgm
nkgm / controllers.application.js
Last active May 9, 2017 20:06 — forked from alexspeller/controllers.application.js
array.length != array.[]
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(" ");
}),