3

Am using ember-engines in my project, After user lands in host ember application, I want my other ember engines to preload (say after 10 seconds), so that when user navigates to other tabs, there wont be any lag in UI.. i dont want to disable lazyLoading of my ember engines since that will increase the size of vendor js and css of host app during initial load.. Any reference for this is appreciated (I was not able to find any example or reference for this).

Praveen Kumar
  • 946
  • 3
  • 10
  • 29

1 Answers1

3

We can use loadBundle method of asset-loader service included by ember-engine as follow:

assetLoader: service(),

preloadEngine() {
  this.assetLoader.loadBundle('<name of the engine>');
}

The loadBundle method return a promise and resolves when the engine bundle loads successfully.

Gokul Kathirvel
  • 1,590
  • 1
  • 10
  • 20
  • Followed the same in host application route.js.. getting this.assetLoader.loadBundle is not a function error... in node-modules folder of host app, there is ember-asset-loader folder too.. Am i missing anything? – Praveen Kumar Jun 10 '20 at 18:58
  • 1
    just replaced below statement: this.assetLoader.loadBundle(name) with this.get('assetLoader').loadBundle(name) and it worked... thank you... – Praveen Kumar Jun 11 '20 at 05:59