Skip to content

Instantly share code, notes, and snippets.

@Rizary
Created August 19, 2019 23:42
Show Gist options
  • Save Rizary/82cd31fcdaf1b09047e4eb50a98159c0 to your computer and use it in GitHub Desktop.
Save Rizary/82cd31fcdaf1b09047e4eb50a98159c0 to your computer and use it in GitHub Desktop.
window <- DOM.currentWindowUnchecked
history <- Window.getHistory window
location <- Window.getLocation window
oldUri <- (decodeFrag . T.pack . uriFragment) <$> getLocationUri location
backState <- wrapDomEvent window (`DOM.on` DOM.popState) $ do
e <- DOM.event
jV <- PopStateEvent.getState e
oUri <- liftJSM $ fromJSVal jV
pure $ decodeFrag $ fromMaybe (T.pack "") oUri
setState <- performEvent $ attachWith (switchRoutingState' history) (current route) changeStateE
route <- foldDynMaybe switchFrag oldUri $ setState
(result, changeStateE) <- runSetRouteT $ strictDynWidget_ app route
pure result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment