Skip to content

Instantly share code, notes, and snippets.

@averydev
Last active December 29, 2017 20:50
Show Gist options
  • Save averydev/0cb04b4e88f3c97db86b7d6a1aa7a874 to your computer and use it in GitHub Desktop.
Save averydev/0cb04b4e88f3c97db86b7d6a1aa7a874 to your computer and use it in GitHub Desktop.
Async of Swim: Nested Routes. Replace route with Ember Concurrency Task
// routes/blog/comments.js
model: function (params){
return {
comments: this.get('commentsTask').perform()
};
},
commentsTask: task(function *(){
let blog = yield this.modelFor('blog').blogTask;
let comments = yield blog.get('comments');
return comments;
})
//Updated new router.js
Router.map(function() {
this.route('blog',{path:"/blog/:blog_id"}, function (){
this.route('comments', {path:"/comments"});
});
});
// comments.hbs
{{#if model.comments.isRunning}}
LOADING COMMENTS
{{else}}
{{#each model.comments.value as |aComment|}}
{{aComment.title}}<br>
{{/each}}
{{/if}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment