Skip to content

Instantly share code, notes, and snippets.

@rizary
Created August 19, 2019 23:40
Show Gist options
  • Select an option

  • Save rizary/779682ada7afb5e0ba2d20b3419acc69 to your computer and use it in GitHub Desktop.

Select an option

Save rizary/779682ada7afb5e0ba2d20b3419acc69 to your computer and use it in GitHub Desktop.
window <- DOM.currentWindowUnchecked
location <- Window.getLocation window
history <- Window.getHistory window
let getCurrentHistoryItem = HistoryItem
<$> History.getState history
<*> getLocationUri location
item0 <- liftJSM getCurrentHistoryItem
itemSetInternal <- performEvent $ ffor runCmd $ \cmd -> liftJSM $ do
runHistoryCommand history cmd
getCurrentHistoryItem
itemSetExternal <- wrapDomEvent window (`DOM.on` DOM.popState) $ do
e <- DOM.event
HistoryItem
<$> (SerializedScriptValue <$> PopStateEvent.getState e)
<*> getLocationUri location
holdDyn item0 $ leftmost [itemSetInternal, itemSetExternal]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment