How to use the ember-concurrency.waitForProperty 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 / events-example / component.js View on Github external
baz: task(function * () {
    let val = yield waitForProperty(this, 'bazValue', (v) => v % 2 === 0);
    yield timeout(500);
    this.set('state', `${this.state} Baz got even value ${val}.`);
  }),
// END-SNIPPET
github TryGhost / Ghost-Admin / lib / koenig-editor / addon / services / koenig-drag-drop-handler.js View on Github external
let onUp = () => {
            this._waitForDragStart.cancelAll();
        };

        // give preference to native drag/drop handlers
        let onHtmlDrag = () => {
            this._waitForDragStart.cancelAll();
        };

        // register local events
        document.addEventListener('mousemove', onMove, {passive: false});
        document.addEventListener('mouseup', onUp, {passive: false});
        document.addEventListener('drag', onHtmlDrag, {passive: false});

        try {
            yield waitForProperty(this, '_dragStartConditionsMet');
        } finally {
            // finally is always called on task cancellation
            this.set('_dragStartConditionsMet', false);
            document.removeEventListener('mousemove', onMove, {passive: false});
            document.removeEventListener('mouseup', onUp, {passive: false});
            document.removeEventListener('drag', onHtmlDrag, {passive: false});
        }
    }).keepLatest(),
github TryGhost / Ghost-Admin / app / components / gh-search-input.js View on Github external
performSearch: task(function* (term) {
        if (isBlank(term)) {
            return [];
        }

        // start loading immediately in the background
        this.refreshContent.perform();

        // debounce searches to 200ms to avoid thrashing CPU
        yield timeout(200);

        // wait for any on-going refresh to finish
        if (this.refreshContent.isRunning) {
            yield waitForProperty(this, 'refreshContent.isIdle');
        }

        // set dependent CP term and re-calculate CP
        this.set('currentSearch', term);
        return this.groupedContent;
    }).restartable(),
github hummingbird-me / hummingbird-client / app / services / algolia.js View on Github external
getIndex: task(function* (name) {
    if (this.keys[name]) {
      return this.keys[name];
    } else if (this.getKeys.isRunning) { // eslint-disable-line no-else-return
      yield waitForProperty(this, 'keys', k => Object.keys(k).length > 0);
    } else {
      const keys = yield this.getKeys.perform();
      this.set('keys', keys);
    }

    const info = this.keys[name];
    if (isEmpty(info)) { return null; }

    const client = algoliasearch(config.algolia.appId, info.key);
    const index = client.initIndex(info.index);
    this.keys[name] = index;
    return index;
  })
});
github machty / ember-concurrency / tests / dummy / app / components / events-example / component.js View on Github external
bar: task(function * () {
    yield waitForProperty(this, 'foo.isIdle');
    this.set('state', `${this.state} Foo is idle.`);
    yield timeout(500);
    this.set('bazValue', 42);
    this.set('state', `${this.state} Bar.`);
  }),
github cardstack / portfolio / cards / portfolio / addon / components / isolated.js View on Github external
async init() {
    this._super(arguments);

    if (this.web3.provider && this.web3.provider.isMetaMask) {
      await waitForProperty(this, 'isWeb3Loaded');
      let address = this.web3.address;
      await this.getPortfolio.perform(address);
    }

    this.set('loadingAssets', false);
  },