Last active
October 6, 2016 21:54
-
-
Save scottmessinger/84e7c2c5b6eca22492ee787810c37092 to your computer and use it in GitHub Desktop.
playing with immutable.js
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.Component.extend({ | |
didReceiveAttrs(){ | |
this._super(...arguments) | |
console.log('didReceiveAttrs', 'my-child') | |
} | |
}); |
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.Component.extend({ | |
internal: true, | |
didReceiveAttrs(){ | |
this._super(...arguments) | |
console.log('didReceiveAttrs', 'my-other-child') | |
} | |
}); |
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.Component.extend({ | |
didReceiveAttrs(){ | |
this._super(...arguments) | |
console.log('didReceiveAttrs', 'my-other-other-child') | |
}, | |
didRender(){ | |
this._super(...arguments) | |
console.log('didRender') | |
} | |
}); |
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.Component.extend({ | |
}); |
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', | |
data: Immutable.Map({ | |
a: Immutable.Map({"one": 1}), | |
b: Immutable.Map({"one": 100}) | |
}), | |
actions: { | |
increment(){ | |
let oldB = Ember.get(this, 'data').get('b') | |
let oldVal = Ember.get(this, 'data').getIn(['a', 'one']) | |
let map = Ember.get(this, 'data').setIn(['a', 'one'], oldVal + 1) | |
let newB = map.get('b') | |
console.log('did I change b', oldB === newB) | |
Ember.set(this, 'data', map) | |
} | |
} | |
}); |
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 function iGet(params/*, hash*/) { | |
return params[0].get(params[1]) | |
} | |
export default Ember.Helper.helper(iGet); |
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
{ | |
"version": "0.10.5", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "beta", | |
"ember-data": "2.8.0", | |
"ember-template-compiler": "beta", | |
"ember-testing": "beta", | |
"immutable": "https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.1/immutable.min.js" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment