Last active
December 23, 2016 18:43
-
-
Save fsmanuel/d829d2cdad86f5804ee9f3c139303b9d to your computer and use it in GitHub Desktop.
Ember readsWithDefault CP
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 { | |
getWithDefault, | |
computed | |
} = Ember; | |
function readsWithDefault(dependentKey, defaultValue) { | |
return computed(dependentKey, { | |
get() { | |
return getWithDefault(this, dependentKey, defaultValue); | |
}, | |
set(key, value) { | |
return value; | |
} | |
}); | |
} | |
export default Ember.Component.extend({ | |
open: readsWithDefault('isOpen', false), | |
actions: { | |
toggleDropDown() { | |
this.toggleProperty('open'); | |
} | |
} | |
}); |
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({ | |
isOpen: false, | |
actions: { | |
toggleDropDown() { | |
this.toggleProperty('isOpen'); | |
} | |
} | |
}); |
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.10.7", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.10.0", | |
"ember-data": "2.10.0", | |
"ember-template-compiler": "2.10.0", | |
"ember-testing": "2.10.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment