Skip to content

Instantly share code, notes, and snippets.

@adriancooney
Last active April 8, 2019 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adriancooney/b41987ef6cfa2f2d3346fef23def60bd to your computer and use it in GitHub Desktop.
Save adriancooney/b41987ef6cfa2f2d3346fef23def60bd to your computer and use it in GitHub Desktop.
Ember 3.4 Scheduler Issue
import Ember from 'ember';
import { later, debounce } from '@ember/runloop';
export default Ember.Controller.extend({
sync(schedulerType) {
console.log("syncing via", schedulerType);
},
actions: {
case1() {
console.log("Case 1");
debounce(this, this.sync, "debounce", 1000);
later(this, this.sync, "later", 5000);
setTimeout(console.log, 5000, "Case 1 complete");
},
case2() {
console.log("Case 2");
later(this, this.sync, "later", 5000);
debounce(this, this.sync, "debounce", 1000);
setTimeout(console.log, 5000, "Case 2 complete");
},
case3() {
console.log("Case 3");
later(this, (arg) => this.sync(arg), "later", 5000);
debounce(this, this.sync, "debounce", 1000);
setTimeout(console.log, 5000, "Case 3 complete");
},
}
});
<h1>Welcome to {{appName}}</h1>
<button {{action 'case1'}}>Case 1</button>
<button {{action 'case2'}}>Case 2</button>
<button {{action 'case3'}}>Case 3</button>
{
"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"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment