Skip to content

Instantly share code, notes, and snippets.

@gregtap
Last active November 6, 2015 07:14
Show Gist options
  • Select an option

  • Save gregtap/749552635bd1cd86db1b to your computer and use it in GitHub Desktop.

Select an option

Save gregtap/749552635bd1cd86db1b to your computer and use it in GitHub Desktop.
export default Component.extend({
tagName: 'time',
ticker: inject.service('ticker'),
timeago: Ember.computed('ticker.tick', function() {
return utils.timeAgoString(this.get('date'));
}),
});
Issue:
The dom seems to get updated every second even if the content of timeago did not change.
http://public.coulix.s3.amazonaws.com/blink_.gif
export function initialize(application) {
application.inject('component', 'ticker', 'service:ticker');
}
export default {
name: 'application',
initialize: initialize,
};
import Ember from 'ember';
const { Service, run } = Ember;
export default Service.extend({
init: function() {
run.later(this, this.giveMeATick, 1000);
},
giveMeATick: function() {
this.set('tick', true);
console.log('I SAID TICK!');
run.later(this, this.giveMeATick, 1000);
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment