Skip to content

Instantly share code, notes, and snippets.

@joliss
Last active December 12, 2015 06:58
Show Gist options
  • Save joliss/4733411 to your computer and use it in GitHub Desktop.
Save joliss/4733411 to your computer and use it in GitHub Desktop.
App.Router.map ->
@resource 'filteredArticles', path: '/:filter'
App.FilteredArticlesRoute = Ember.Route.extend
model: (params) ->
blog = App.Blog.find(1) # get the user's Blog singleton
property = switch params.filter
when 'published' then 'publishedArticles'
when 'draft' then 'drafts'
when 'all' then 'articles'
# Return the list of articles from the `blog` record.
# But `blog` hasn't necessarily finished loading :(
blog.get(property)
# In general: How can we return something from `model` that needs
# asynchronous callbacks to load?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment