getPostBuild seems to fire too fast?
augyg opened this issue · comments
Recently I've faced a different issue when using Obelisk so the following is a hack around that issue (see: obsidiansystems/obelisk#962) however this feels worth reporting.
The hack was using getPostBuild to force the page's HTML to render before the javascript to getUserMedia however with:
pb <- getPostBuild
prerender_ blank $ performEvent_ ((liftJSM $ clog ("hey" :: T.Text)) <$ pb)
"hey" is never logged, but if I use delay like so:
p <- getPostBuild
p' <- delay 0.00000000001 p
And instead use p' in-place of pb it works. I've played around with this number and If I make the time slightly smaller it has the same effect as before where the Event never "seems" to fire.
Partially motivated to reporting since it seems expected that getPostBuild would have this effect without delay, and I suspect the code (clog ~ console.log) hasn't been written yet given the tiny delay?
Also curious how PostBuild and hydration switchover are supposed to interact. Does it work as intended if you do
prerender_ blank $ do
pb <- getPostBuild
performEvent_ ((liftJSM $ clog ("hey" :: T.Text)) <$ pb)
@alexfmpe your code actually works as intended