Skip to content

Instantly share code, notes, and snippets.

@buschtoens
Created April 25, 2017 07:23
Show Gist options
  • Save buschtoens/b23fdbd6e736822f1c9ccb7ca7c8e939 to your computer and use it in GitHub Desktop.
Save buschtoens/b23fdbd6e736822f1c9ccb7ca7c8e939 to your computer and use it in GitHub Desktop.
computed property diffing
import Ember from 'ember';
export default Ember.Component.extend({
lastUpdate: null,
didReceiveAttrs() {
this._super(...arguments);
this.set('lastUpdate', Date.now());
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
currentDate: null,
isOld: Ember.computed('currentDate', () => false),
init() {
this._super(...arguments);
this.updateCurrentDate();
setInterval(() => this.updateCurrentDate(), 1000);
},
updateCurrentDate() {
this.set('currentDate', Date.now());
}
});
currentDate: {{currentDate}}<br>
isOld: {{isOld}}<hr>
{{my-component isOld=isOld}}
{
"version": "0.12.1",
"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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment