How to use the ember-concurrency.asyncIterator function in ember-concurrency

To help you get started, we’ve selected a few ember-concurrency 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 machty / ember-concurrency / tests / dummy / app / components / async-iterator / component.js View on Github external
myTask: task(function * () {
    this.set('value', "START");
    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(),