Skip to content

Instantly share code, notes, and snippets.

@jkarsrud
Created July 17, 2015 11:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkarsrud/e4bb48c5755973655181 to your computer and use it in GitHub Desktop.
Save jkarsrud/e4bb48c5755973655181 to your computer and use it in GitHub Desktop.
New Twiddle
export default Ember.Component.extend({
interval: 1000,
timer: null,
startTimer() {
const timer = Ember.run.later(this, () => {
this.sendAction('tick');
this.startTimer();
}, this.get('interval'));
this.set('timer', timer);
},
cancelTimer() {
Ember.run.cancel(this.get('timer'));
},
didInsertElement() {
this.startTimer();
},
actions: {
start() {
this.startTimer();
},
cancel() {
this.cancelTimer();
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
count: 0,
actions: {
countIt() {
this.incrementProperty('count');
}
}
});
{{count}}
{{counter-thingy tick="countIt"}}
<button {{action 'cancel'}}>Stop counting</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment