Class: ForeverYieldable


Yielding forever will pause a task indefinitely until it is cancelled (i.e. via host object destruction, .restartable(), or manual cancellation).

This is often useful in cases involving animation: if you're using Liquid Fire, or some other animation scheme, sometimes you'll notice buttons visibly reverting to their inactive states during a route transition. By yielding forever in a Component task that drives a button's active state, you can keep a task indefinitely running until the animation runs to completion.

NOTE: Liquid Fire also includes a useful waitUntilIdle() method on the liquid-fire-transitions service that you can use in a lot of these cases, but it won't cover cases of asynchrony that are unrelated to animation, in which case forever might be better suited to your needs.

import { task, forever } from 'ember-concurrency';

export default Component.extend({
  myService: service(),
  myTask: task(function * () {
    yield this.myService.doSomethingThatCausesATransition();
    yield forever;