lucamug/elm-starter

Wait for XHR to complete

sevfurneaux opened this issue · 2 comments

First of all – great project!

I wondered: would it be possible to "wait" for an XHR request to complete before the page is statically rendered?

For example, an Elm app on init could make a Http.get request and then perform an update.

At the moment, the "Loading" state would be statically rendered, while the ideal situation would be it actually renders the requested data.

The more I think about this, the more complex it is 😅

The html generation part is based on puppeteer:

await page.goto(`${conf.startingDomain}${url}`, {waitUntil: 'networkidle0'});

From the documentation:

https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagegotourl-options

Screen Shot 2020-08-23 at 11 26 08

Other info at puppeteer/puppeteer#1552

I should probably add this as parameter as different website could have different preference