Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadDataTask = function*({ paginationData, sortData, filterData }) {
yield timeout(250);
let params = {
sortBy: sortData.map((s) => s.prop),
sortDir: sortData.map((s) => s.direction),
pageNumber: paginationData.pageNumber,
pageSize: paginationData.pageSize,
filter: filterData.filter
};
let users = yield this.store.query('user', params);
// we need to inform Yeti Table about the total number of rows
// for pagination to work correctly. Check out the pagination guide.
this.set('totalRows', users.get('meta.totalRows'));
return users;
return o;
}
// BEGIN-SNIPPET modal-fun-controller
import { task, timeout, taskGroup } from 'ember-concurrency';
let PAUSE_FOREVER = Ember.RSVP.defer().promise;
export default Ember.Controller.extend({
openWizard: task({
perform: function * () {
this.get('stepOne').perform();
yield PAUSE_FOREVER;
},
states: taskGroup().restartable(),
currentState: alias('states.last'),
next: taskByName('next'),
prev: taskByName('prev'),
stepOne: state({
title: "Step 1",
next: 'stepTwo',
index: 0,
}),
stepTwo: state({
perform: function * () {
while (true) {
yield timeout(500);
this.set('title', reverse(this.title));
import { computed } from '@ember/object';
import Controller from '@ember/controller';
import { taskGroup } from 'ember-concurrency';
// BEGIN-SNIPPET task-groups
export default Controller.extend({
everything: taskGroup(),
everythingDropped: taskGroup().drop(),
everythingEnqueue: taskGroup().enqueue(),
everythingRestart: taskGroup().restartable(),
everythingDropped3: taskGroup().maxConcurrency(3).drop(),
everythingEnqueue3: taskGroup().maxConcurrency(3).enqueue(),
everythingRestart3: taskGroup().maxConcurrency(3).restartable(),
taskGroups: computed(function () {
return [
this.get('everything'),
this.get('everythingDropped'),
this.get('everythingEnqueue'),
this.get('everythingRestart'),
this.get('everythingDropped3'),
this.get('everythingEnqueue3'),
this.get('everythingRestart3'),
];
import { computed } from '@ember/object';
import Controller from '@ember/controller';
import { taskGroup } from 'ember-concurrency';
// BEGIN-SNIPPET task-groups
export default Controller.extend({
everything: taskGroup(),
everythingDropped: taskGroup().drop(),
everythingEnqueue: taskGroup().enqueue(),
everythingRestart: taskGroup().restartable(),
everythingDropped3: taskGroup().maxConcurrency(3).drop(),
everythingEnqueue3: taskGroup().maxConcurrency(3).enqueue(),
everythingRestart3: taskGroup().maxConcurrency(3).restartable(),
taskGroups: computed(function () {
return [
this.get('everything'),
this.get('everythingDropped'),
this.get('everythingEnqueue'),
this.get('everythingRestart'),
this.get('everythingDropped3'),
this.get('everythingEnqueue3'),
this.get('everythingRestart3'),
];
}),
});
// END-SNIPPET
waiter: task(function * () {
let event = yield waitForEvent(document.body, 'click');
return event;
}),
// END-SNIPPET
emberEventedLoop: task(function * () {
while(true) {
let event = yield waitForEvent(this, 'fooEvent');
this.set('emberEvent', event);
}
}).on('didInsertElement'),
// END-SNIPPET
let obs = window.Rx.Observable.interval(100).take(50 + 1).do(v => {
if (!this.isDestroyed) {
this.set('obsValue', v);
}
});
let ai = asyncIterator(obs);
if (this.bufferType) {
ai[this.bufferType]();
}
while (true) {
let { value, done } = yield ai.next();
if (done) { break; }
this.set('value', value);
yield sleep(300); // pretend to be some async work
}
}).autoStart(),
beepOscillator.frequency.value = 300;
let beepGain = context.createGain();
beepGain.gain.value = 0;
beepOscillator.connect(beepGain);
beepOscillator.type = 'triangle';
beepGain.connect(context.destination);
beepOscillator.start(0);
let bps = this.get('bpm') / 60.0;
let halfTimeout = 1 / bps / 2 * 1000;
// sleep randomly so that multiple x-musics don't annoying start at the same time.
yield sleep(Math.random() * 1000);
for (;;) {
// main
beepOscillator.frequency.value = 100 + Math.random() * 600;
beepGain.gain.setTargetAtTime(0.5, context.currentTime, 0.01);
this.set('isPlaying', true);
yield sleep(halfTimeout);
beepGain.gain.setTargetAtTime(0, context.currentTime, 0.01);
this.set('isPlaying', false);
yield sleep(halfTimeout);
}
} finally {
if (context) {
context.close();
}
myTask: task(function * () {
this.set('value', "START");
let ai = asyncIterator.fromEvent(this, 'onEvent');
if (this.bufferType) {
ai[this.bufferType]();
}
while (true) {
let { value, done } = yield ai.next();
if (done) { break; }
this.set('value', value.foo);
yield sleep(800); // pretend to be some async work
}
}).autoStart(),
beepGain.connect(context.destination);
beepOscillator.start(0);
let bps = this.get('bpm') / 60.0;
let halfTimeout = 1 / bps / 2 * 1000;
// sleep randomly so that multiple x-musics don't annoying start at the same time.
yield sleep(Math.random() * 1000);
for (;;) {
// main
beepOscillator.frequency.value = 100 + Math.random() * 600;
beepGain.gain.setTargetAtTime(0.5, context.currentTime, 0.01);
this.set('isPlaying', true);
yield sleep(halfTimeout);
beepGain.gain.setTargetAtTime(0, context.currentTime, 0.01);
this.set('isPlaying', false);
yield sleep(halfTimeout);
}
} finally {
if (context) {
context.close();
}
if (beepOscillator) {
beepOscillator.stop();
}
}
}).autoStart(),