Skip to content

Instantly share code, notes, and snippets.

@golampo
Last active December 14, 2018 17:34
Show Gist options
  • Save golampo/3fbb77ced057a289db1cf9440bf06179 to your computer and use it in GitHub Desktop.
Save golampo/3fbb77ced057a289db1cf9440bf06179 to your computer and use it in GitHub Desktop.
ember-lifeline - cancelPoll not working
import Ember from 'ember';
import { runTask, pollTask, cancelPoll } from 'ember-lifeline';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
count: 0,
actions: {
startPoll() {
this.set('isPolling', true);
this.pollToken = pollTask(this, (next) => {
this.incrementProperty('count');
runTask(this, next, 1000);
});
},
stopPoll() {
this.set('isPolling', false);
cancelPoll(this, this.pollToken);
}
}
});
<h1>Welcome to {{appName}}</h1>
{{outlet}}
{{#if isPolling}}
<button {{action "stopPoll"}}>Stop poll</button>
{{else}}
<button {{action "startPoll"}}>Start poll</button>
{{/if}}
<br>
<br>
Counter: {{count}}
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2",
"ember-lifeline": "3.0.9"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment