Route.setupController pause on promises -- could solve two related problems


I have two related problems which could be solved by having Route.setupController pause to resolve any promises before proceeding to render.

I have a sidebar menu which is populated with data from models retrieved via async relationships. To get the data, I use the afterModel hook to load these models in promises. To pass this on to the controller, I replace the actual model with a hash containing { model: model } in the model() hook, then add the menu info to that hash in the after-model hook.

  1. This means that nested routes are unnecessarily coupled, as they get this whole hash when they call “modelFor”.

  2. When an action modifies a sub-object, the menus have to change. To do this, I add an extra query parameter, and specify the “refreshModel” keyword when this changes.

If setupController were to pause on promises returned from it, I could move the menu-setup code to setupController and dispense with both of these hacks. The change would be backward compatible, as currently what happens when a promise is returned from setupController is undefined.