Skip to content

Instantly share code, notes, and snippets.

@vincentbello
Last active December 14, 2016 18:43
Show Gist options
  • Save vincentbello/f56c2e4d2ef046cecf12b0933a098c12 to your computer and use it in GitHub Desktop.
Save vincentbello/f56c2e4d2ef046cecf12b0933a098c12 to your computer and use it in GitHub Desktop.
routes/product-list.js
export default Ember.Route.extend({
/** Use the url params to fetch the model data */
model(params) {
if (!Ember.isEmpty(params.products)) {
return params.products.map((product) => {
return {
name: product,
taskInstance: this.get('findProductTask').perform(product),
};
});
}
// If no query params are provided, return empty array
return [];
},
/** Task that fetches a product record */
findProductTask: task(function * (productName) {
return yield this.store.findRecord('product', productName);
}),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment