Last active
December 14, 2016 18:43
-
-
Save vincentbello/f56c2e4d2ef046cecf12b0933a098c12 to your computer and use it in GitHub Desktop.
routes/product-list.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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