How to use the ember-concurrency-decorators.task function in ember-concurrency-decorators

To help you get started, we’ve selected a few ember-concurrency-decorators 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 jdaviderb / JFrogfy / src / services / youtube.ts View on Github external
}

  play(track: Track): any {
    if (this.controller && this.task) {
      this.controller.abort();
      this.controller = new AbortController();
      this.signal = this.controller.signal;
      this.task.cancel();
    }
    // @ts-ignore
    this.task = this._load.perform(track);
    return this.task;
  }

  // @ts-ignore
  @task({ maxConcurrency: 2, drop: true })
  *_load(track: Track): any {
    let audio;
    const options = { method: 'get', signal: this.signal };

    try {
      this.audio.pause();
      const queryParams = encodeURI(`?artist=${track.artist}&song=${track.name}`);
      const response = yield fetch(this.host + this.endpoint + queryParams, options);
      const data = yield response.json();
      audio = decodeURIComponent(data.video);
      this.audio.play(audio);
    } catch(error) {
      this.audio.tracksManager.nextPlay();
    }

    return audio;

ember-concurrency-decorators

decorator syntax for declaring/configuring ember-concurrency tasks

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis