Skip to content

Instantly share code, notes, and snippets.

@averydev
Last active December 29, 2017 20:48
Show Gist options
  • Save averydev/3fa031935b00ee5e965da68df9ad75f2 to your computer and use it in GitHub Desktop.
Save averydev/3fa031935b00ee5e965da68df9ad75f2 to your computer and use it in GitHub Desktop.
Async of Swim: basic case. Replace route with Ember Concurrency Task
// In your route...
import Route from '@ember/routing/route';
import { task } from 'ember-concurrency';
export default Route.extend({
model: function (){
return {
blog: this.get('blogTask').perform()
};
},
blogTask: task(function *(){
let blog = yield this.get('store').queryRecord('blog', {today:true});
return blog;
});
});
// In your template...
{{#if model.blog.isRunning}}
LOADING...
{{else}}
{{model.blog.value.title}}
{{/if}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment