Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 1021 Bytes

README.md

File metadata and controls

30 lines (23 loc) · 1021 Bytes

Nested Routing for Reflex-DOM

Haskell Programming Language BSD3 License

Example:

app = runRouteWithPathInFragment $ do
  switchPromptly never <=< withRoute $ \route -> case fromMaybe "" route of
    ""         -> (["users"] <$) <$> buttonClick "Open users"
    "users"    -> users
    "test"     -> codeToRun >> pure never
    "settings" -> text "Settings" >> pure never
    _          -> redirectLocally []

RouteWriter can make plumbing easer:

app = runRouteWithPathInFragment $ fmap snd $ runRouteWriterT $ do
  void $ withRoute $ \route -> case fromMaybe "" route of
    ""         -> tellRouteAs ["users"] =<< buttonClick "Open users"
    "users"    -> users
    "test"     -> codeToRun
    "settings" -> text "Settings"
    _          -> tellRedirectLocally []