jeudi 26 septembre 2019

Ember.js: parallel loading parent and child models

I have these routes:

  • posts
    • index (all the posts)
    • single (with dynamic parameter post_id)
      • index (single post and it's comments view)
      • edit (editing post)

There are two separate requests for fetching post by ID and fetching post comments by post ID. I want to load post and comments for posts.single.index route in parallel, because I have a post ID in route name and I do not have to wait when post will be loaded.

But Ember loads posts.single model, and only AFTER post it loads comments.

Is it possible to call child model in parallel with parent model?

I have found a solution when posts.single does not load anything, and posts.single.index calls two requests in it's own model. On the other hand, I should load post model within all posts.single child routes, such as posts.single.edit. It could be a problem, when application will be grow.




Aucun commentaire:

Enregistrer un commentaire