Last active
August 29, 2015 14:26
-
-
Save jgwhite/254f8474dd6c3c6828bf to your computer and use it in GitHub Desktop.
Observation chain breaks
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'; | |
const { computed, typeOf } = Ember; | |
export default Ember.Component.extend({ | |
value: computed({ | |
set(param, value) { | |
switch(typeOf(value)) { | |
case "string": | |
this._value = value === 'foo' ? 'bar' : value; | |
break; | |
case "boolean": | |
this._value = new Set([String(value)]); | |
break; | |
case 'null': | |
this._value = null; | |
break; | |
default: | |
this._value = value; | |
} | |
return value; | |
}, | |
get() { | |
return this._value; | |
} | |
}) | |
}); |
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'; | |
const { on } = Ember; | |
export default Ember.Controller.extend({ | |
appName:'Observation Change Falls Over', | |
myProp: 'to start with', | |
mySet: null, | |
_mySetInit: on('init', function() { | |
this.set('mySet', new Set(['one','two','three'])); | |
}), | |
actions: { | |
setValue: function(value) { | |
this.set('myProp', value); | |
} | |
} | |
}); |
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
{ | |
"version": "0.4.0", | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.5/ember.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.5/ember-data.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment