Created
June 12, 2020 14:18
-
-
Save scottmessinger/f35425216d22e1e05bd96e1708742d6d to your computer and use it in GitHub Desktop.
Application route for delaying loading until components have finished.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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