Hello,
I am using blaze with dynamic imports, this is working fine when I don’t specify a layout
This is working fine (except the text iron_core.js Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?)
Unfortunately they don’t support the usual async handling, and instead use Meteor’s reactivity, re-running the function when a dependency changes and waiting until the function returns truthy.
This means you’ll need to use a ReactiveVar to get it working:
Router.route('/test-route-with-layout-not-working', {
loadingTemplate: 'loading',
waitOn() {
// Return a function that gets run reactively
return () => {
// when we're loaded return true to continue. This also registers a dependency on state
if (this.state.get('testRouteLoaded')) return true;
import('./test-route.js').then(() => {
// changing the state will get waitOn to re-run, which will return true
this.state.set('testRouteLoaded', true);
});
};
},
action() {
this.layout('mobileLayout');
this.render('testRoute');
});