iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 413 forks source link

Target loadingTemplate to specific nested templates #638

Open chadokruse opened 10 years ago

chadokruse commented 10 years ago

Similar to yieldTemplate, but for loadingTemplate.

E.g. this:

layoutTemplate: 'layout',

can be expanded to this:

loadingTemplates: {
  'adDummy': {to: 'sidebarContent'},
  'feedDumymy': {to: 'newsFeed'},
},

Would allow for the use of "optimistic rendering" similar to what Facebook does with its main news feed. With complex layouts I could show one template "dummy" for one nested template, and another "dummy" for another nested template under the same {{> yield}}. See discussion here.

On a more simplistic level, it would allow for targeting spinners to just the nested templates involving data, as discussed in this SO question.

tmeasday commented 10 years ago

I think this is a good idea. @cmather - what do you think?

Possibly the right approach (at least to begin with) is to make a package for this. That way we can let the API for it mature without affecting IR in the meantime.

cmather commented 10 years ago

Yeah let's play around. I would start with the refactor branch. You could do something like this:

Router.plugin('loading', {
  loadingTemplates: {
    ....
  }
});

Iron.Router.plugins.loading = function (router, options) {
  Router.onBeforeAction(function () {
    var templates = this.lookupOption('loadingTemplates');
    ...
  }, options);
};
arboleya commented 9 years ago

Any progress on this?