Skip to content

Instantly share code, notes, and snippets.

@alexdiliberto
Last active January 15, 2018 16:39
Show Gist options
  • Save alexdiliberto/4cdaaa04a1e65237c74d3c1a306197e6 to your computer and use it in GitHub Desktop.
Save alexdiliberto/4cdaaa04a1e65237c74d3c1a306197e6 to your computer and use it in GitHub Desktop.
ember-concurrency Tips and Tricks

Using ember-concurrency to easily load data inside a component

import { task } from 'ember-concurrency';
import { readOnly } from '@ember/object/computed';

export default Component.extend({
  tags: readOnly('loadTags.lastSuccessful.value'),

  loadTags: task(function * () {
    return yield this.get('store').findAll('tags');
  }).on('init')
});
{{#each tags as |tag|}}
  {{tag.name}}
{{/each}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment