How to use the ember-concurrency.timeout 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 miguelcobain / ember-yeti-table / tests / dummy / app / pods / docs / async / controller.js View on Github external
loadDataTask = function*({ paginationData, sortData, filterData }) {
    yield timeout(250);

    let params = {
      sortBy: sortData.map((s) => s.prop),
      sortDir: sortData.map((s) => s.direction),
      pageNumber: paginationData.pageNumber,
      pageSize: paginationData.pageSize,
      filter: filterData.filter
    };

    let users = yield this.store.query('user', params);

    // we need to inform Yeti Table about the total number of rows
    // for pagination to work correctly. Check out the pagination guide.
    this.set('totalRows', users.get('meta.totalRows'));

    return users;
github peopleconnectus / ember-concurrency-scroll / addon / services / scroller.js View on Github external
dirX = -1;
    }
    // Ember.Logger.log(start, end, `tx:${targetX}, ty:${targetY}, ox:${offsetX}, oy:${offsetY}, ${axis}`)
    while (index < steps) {
      if (axis === 'x') {
        // scroll x axis
        scrollTo(eases[index] * targetX * dirX + offsetX, startY);
      } else if (axis === 'xy' || axis === 'both') {
        // scroll x and y axis
        scrollTo(eases[index] * targetX * dirX  + offsetX,  eases[index] * targetY * dirY + offsetY);
      } else {
        // scroll y axis
        scrollTo(startX,  eases[index] * targetY * dirY + offsetY);
      }
      index++;
      yield timeout(delay);
    }
  }).keepLatest(),
github TryGhost / Ghost-Admin / app / components / gh-download-count.js View on Github external
_poll: task(function* () {
        let url = this.get('ghostPaths.count');
        let pattern = /(-?\d+)(\d{3})/;

        try {
            let data = yield this.ajax.request(url);
            let count = data.count.toString();

            while (pattern.test(count)) {
                count = count.replace(pattern, '$1,$2');
            }

            this.set('count', count);

            if (config.environment !== 'test') {
                yield timeout(2000);
                this._poll.perform();
            }
        } catch (e) {
            // no-op - we don't want to create noise for a failed download count
        }
    })
});
github TryGhost / Ghost-Admin / app / mixins / editor-base-controller.js View on Github external
_autosave: task(function* () {
        if (!this.get('_canAutosave')) {
            return;
        }

        // force an instant save on first body edit for new posts
        if (this.get('post.isNew')) {
            return this.get('autosave').perform();
        }

        yield timeout(AUTOSAVE_TIMEOUT);
        this.get('autosave').perform();
    }).restartable(),
github TryGhost / Ghost-Admin / app / components / gh-profile-image.js View on Github external
yield timeout(this.debounce);

        let email = this.email;

        if (validator.isEmail(email || '')) {
            let size = this.size;
            let gravatarUrl = `//www.gravatar.com/avatar/${md5(email)}?s=${size}&d=404`;

            try {
                // HEAD request is needed otherwise jquery attempts to process
                // binary data as JSON and throws an error
                yield request(gravatarUrl, {type: 'HEAD'});
                // gravatar exists so switch style and let browser load it
                this._setAvatarImage(gravatarUrl);
                // wait for fade-in animation to finish before removing placeholder
                yield timeout(ANIMATION_TIMEOUT);
                this._setPlaceholderImage('');
            } catch (e) {
                // gravatar doesn't exist so make sure we're still showing the placeholder
                this._setPlaceholderImage(this._defaultImageUrl);
                // then make sure the avatar isn't visible
                this._setAvatarImage('');
            }
        }
    }).restartable(),
github hashicorp / levant / vendor / github.com / hashicorp / nomad / ui / app / components / allocation-row.js View on Github external
fetchStats: task(function*() {
    do {
      if (this.stats) {
        try {
          yield this.get('stats.poll').perform();
          this.set('statsError', false);
        } catch (error) {
          this.set('statsError', true);
        }
      }

      yield timeout(500);
    } while (this.enablePolling);
  }).drop(),
});
github nickschot / ember-model-select / addon / components / model-select.js View on Github external
searchModels: withTestWaiter(task(function* (term, options, initialLoad = false) {
    let createOption;

    if(this.get('withCreate') && term){
      createOption = {
        __value__: term,
        __isSuggestion__: true
      };
      createOption[this.get('labelProperty')] = this.get('buildSuggestion')
        ? this.get('buildSuggestion')(term)
        : `Add "${term}"...`;
      this.set('_options', A([createOption]));
    }

    if(!initialLoad){
      yield timeout(this.get('debounceDuration'));
    }

    yield this.get('loadModels').perform(term, createOption);
  }).restartable()),
github GavinJoyce / ember-present / addon / components / x-video-slide.js View on Github external
stop: task(function * (delay) {
    yield timeout(delay);
    this.$()[0].pause();
  }).drop()
});
github ilios / frontend / app / components / course-rollover.js View on Github external
save: task(function * (){
    this.set('isSaving', true);
    yield timeout(10);
    this.send('addErrorDisplaysFor', ['title', 'selectedYear']);
    let {validations} = yield this.validate();

    if (validations.get('isInvalid')) {
      this.set('isSaving', false);
      return;
    }
    const commonAjax = this.get('commonAjax');
    const courseId = this.get('course.id');
    const expandAdvancedOptions = this.get('expandAdvancedOptions');
    const year = this.get('selectedYear');
    const newCourseTitle = this.get('title');
    const selectedCohortIds = this.get('selectedCohorts').mapBy('id');
    let newStartDate = moment(this.get('startDate')).format('YYYY-MM-DD');
    let skipOfferings = this.get('skipOfferings');