How to use the ember-animated/-private/ember-scheduler.task function in ember-animated

To help you get started, we’ve selected a few ember-animated examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ember-animation / ember-animated / addon-test-support / motion-tester.js View on Github external
() => 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(),
});
github ember-animation / ember-animated / tests / dummy / app / components / each-example.js View on Github external
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() {
github ember-animation / ember-animated / tests / dummy / app / components / item-list-example.js View on Github external
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({
github ember-animation / ember-animated / tests / dummy / app / components / item-list-example.js View on Github external
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) {