Skip to content

Instantly share code, notes, and snippets.

@scottmessinger
Created June 12, 2020 14:18
Show Gist options
  • Save scottmessinger/f35425216d22e1e05bd96e1708742d6d to your computer and use it in GitHub Desktop.
Save scottmessinger/f35425216d22e1e05bd96e1708742d6d to your computer and use it in GitHub Desktop.
Application route for delaying loading until components have finished.
export default class ApplicationRoute extends Route {
model(params, transition) {
if (this.fastboot && this.fastboot.isFastBoot) {
let promise = new Promise((resolve, reject) => {
let poll = () => {
later(() => {
if (this.finder.inFlightRequests.length === 0 && this.query.inFlightQueriesCount === 0) {
scheduleOnce("afterRender", this, resolve)
return
} else {
poll()
}
}, 50)
}
poll()
})
this.fastboot.deferRendering(promise)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment