Skip to content

Instantly share code, notes, and snippets.

@Allerby
Last active December 5, 2017 10:52
Show Gist options
  • Save Allerby/9cc65347296b2670e560f0942735c96f to your computer and use it in GitHub Desktop.
Save Allerby/9cc65347296b2670e560f0942735c96f to your computer and use it in GitHub Desktop.
Fastboot and Ember Concurrency?
// Route
import Ember from 'ember';
import { task } from 'ember-concurrency';
export default Ember.Route.extend({
// This won't work as Fastboot needs the model to be resolved on render.
// A promise could be used to wait for 'getPost' to resolve, but I would lose the usefulness of ember-concurrencies derived state.
model: function(params) {
return {
listing: this.get('getPost').perform(params.post_id),
};
},
getPost: task(function * (postId) {
return yield this.store.findRecord('post', postId)
}),
});
{{!-- Template --}}
{{#if model.post.value}}
{{post.title}}
{{post.description}}
{{/if}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment