Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
() => null,
);
context.insertedSprites;
// Each motion contains its own promise that is used by
// TransitionContext#animate so that a transition can wait for a
// single motion to finish (as opposed to waiting for the whole
// transition Task to finish). In this test harness, there is no
// distinction, and this extra promises will just generate console
// noise if it remains unconsumed.
motion._promise.then(() => {}, () => {});
return this.get('runner').perform(motion);
},
isAnimating: alias('runner.isRunning'),
runner: task(function*(motion) {
this.beforeAnimation(motion);
yield* motion._run();
this.afterAnimation(motion);
}).restartable(),
});
currentSort: numeric,
items: computed({
get() {
let result = [];
for (let i = 0; i < 10; i++) {
result.push(makeRandomItem());
}
return A(result.sort(numeric));
},
set(k, v) {
return A(v);
},
}),
chaos: task(function*(running) {
if (!running) {
return;
}
while (true) {
yield timeout(1000);
this.send('addItem');
yield timeout(1000);
this.send(
'removeItem',
this.get('items')[Math.floor(Math.random() * this.get('items.length'))],
);
}
}).restartable(),
actions: {
addItem() {
motionService: service('-ea-motion'),
currentSort: numeric,
duration: 1000,
items: computed({
get() {
let result = [];
for (let i = 0; i < 10; i++) {
result.push(makeRandomItem());
}
return result.sort(numeric);
},
set(k, v) {
return v;
},
}),
addItem: task(function*() {
this.get('motionService').willAnimate({
task: current,
duration: this.get('duration'),
component: this,
});
let items = this.get('items');
this.set(
'items',
items
.concat([makeRandomItem()])
.sort(this.currentSort)
.map(elt => ({ id: elt.id })),
);
}),
removeItem: task(function*(which) {
this.get('motionService').willAnimate({
addItem: task(function*() {
this.get('motionService').willAnimate({
task: current,
duration: this.get('duration'),
component: this,
});
let items = this.get('items');
this.set(
'items',
items
.concat([makeRandomItem()])
.sort(this.currentSort)
.map(elt => ({ id: elt.id })),
);
}),
removeItem: task(function*(which) {
this.get('motionService').willAnimate({
task: current,
duration: this.get('duration'),
component: this,
});
let items = this.get('items');
this.set(
'items',
items.filter(i => i !== which),
);
}),
actions: {
addItem() {
this.get('addItem').perform();
},
removeItem(which) {