Skip to content

Instantly share code, notes, and snippets.

@averydev
Last active December 27, 2017 04:54
Show Gist options
  • Select an option

  • Save averydev/3f6915c6438a1cde84b26cce1cf52846 to your computer and use it in GitHub Desktop.

Select an option

Save averydev/3f6915c6438a1cde84b26cce1cf52846 to your computer and use it in GitHub Desktop.
Async of Swim: Dynamic Segments.
//In your route
import Route from '@ember/routing/route';
import { task } from 'ember-concurrency';
export default Route.extend({
model: function (params){
return {
blog: this.get('blogTask').perform(params.blog_id)};
},
blog: task(function *(blogId){
let blog = yield this.get('store').findRecord('blog', blogId );
return blog;
})
});
Router.map(function() {
this.route('blog',{path:"/blog/:blog_id"});
});
//Stays the same
{{#if model.blogTask.isRunning}}
LOADING...
{{else}}
{{model.blog.title}}
{{/if}}
@xomaczar

Copy link
Copy Markdown

blogTask does not exist. The task is ‘blog’

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment