Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getPostBuild seems to fire too fast? #488

Closed
augyg opened this issue Jan 12, 2023 · 3 comments
Closed

getPostBuild seems to fire too fast? #488

augyg opened this issue Jan 12, 2023 · 3 comments

Comments

@augyg
Copy link

augyg commented Jan 12, 2023

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?

@alexfmpe
Copy link
Member

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)

@augyg
Copy link
Author

augyg commented Jan 12, 2023

@alexfmpe your code actually works as intended

@augyg
Copy link
Author

augyg commented May 25, 2024

-- | Fire some logic right now and return result as an Event
performPostBuildEvent :: (PostBuild t m, PerformEvent t m) => Performable m b -> m (Event t b)
performPostBuildEvent f = getPostBuild >>= performEvent . (f <$)

@augyg augyg closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants