Skip to content

Instantly share code, notes, and snippets.

@ofersadgat
ofersadgat / controllers.application.js
Last active April 15, 2018 15:02
Computed Update Count
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
counter: 0,
callCount: 0,
ocallCount: 0,
setCounter: Ember.on('init', function(){
@ofersadgat
ofersadgat / controllers.application.js
Last active December 9, 2016 01:21
Property compute is expensive
import Ember from 'ember';
var fib = function(n){
switch(n){
case 0: return 0;
case 1: return 1;
default: return fib(n-1) + fib(n-2);
}
};
@ofersadgat
ofersadgat / controllers.application.js
Last active December 8, 2016 22:34
Property compute is expensive - with shortcut
import Ember from 'ember';
var fib = function(n){
switch(n){
case 0: return 0;
case 1: return 1;
default: return fib(n-1) + fib(n-2);
}
};
import Ember from 'ember';
var ComputedProto = Object.getPrototypeOf(Ember.computed(function(){}));
var isComputed = function(obj){
return typeof(obj) === 'object' && ComputedProto.isPrototypeOf(obj);
}
var ObserverProto = Object.getPrototypeOf(Ember.observer(function(){}));
var isObserver = function(obj){
return typeof(obj) === 'function' && ObserverProto.isPrototypeOf(obj);
}
@ofersadgat
ofersadgat / components.graph-creator.js
Last active September 30, 2017 00:58
Computed Updates
import Ember from 'ember';
import GraphCreator from '../lib/GraphCreator';
const style = `
body{
margin: 0;
padding: 0;
overflow:hidden;
}