Skip to content

3noch/reflex-dom-nested-routing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 []