mardi 4 septembre 2018

How do I backgroundReload in multiple stages in Ember?

I'm fetching a list of records, say posts, without relationships. When I pick a single post, I would like to see the post immediately, and background-load its relationships.

This is possible like so:

this.store.findRecord('posts', params.id, {
    reload: false,
    backgroundReload: true,

Once the relationships are loaded, the view is automatically updated.

However, some relationships are complex and take some time to load. They become relevant after scrolling. There is one hasMany relationship that is important for the initial pageview. And their relationships are also important, but I prefer to defer them too.

So, is it possible to do the following points in order when clicking on a single post?

  • Open post directly from cache (reload: false)
  • Background-reload including one relationship excluding the relationship's relationships
    • Background-reload relationship including relationship's relationships
  • Background-reload including all relationships

E.g. after the initial template is drawn using the cached model, 3 more updates will happen.




Aucun commentaire:

Enregistrer un commentaire