Skip to content

Instantly share code, notes, and snippets.

@poteto
Last active October 11, 2017 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poteto/12acf37d7d76ee0530018cc4a471805f to your computer and use it in GitHub Desktop.
Save poteto/12acf37d7d76ee0530018cc4a471805f to your computer and use it in GitHub Desktop.
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
const { Component, get, set } = Ember;
export default Component.extend({
tagName: '',
init() {
this._super(...arguments);
this.data = [];
},
didReceiveAttrs() {
let query = get(this, 'query');
get(this, 'fetchData').perform(query);
},
fetchData: task(function*(query) {
yield timeout(1000);
let users = yield get(this, 'store').queryRecord('user', query);
return set(this, 'data', users);
}).restartable()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment