This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-13
Channels
- # adventofcode (36)
- # aleph (1)
- # announcements (7)
- # aws (4)
- # babashka (14)
- # beginners (61)
- # calva (79)
- # cider (19)
- # clojure (48)
- # clojure-austin (1)
- # clojure-australia (2)
- # clojure-czech (2)
- # clojure-europe (46)
- # clojure-france (8)
- # clojure-nl (19)
- # clojure-uk (4)
- # clojuredesign-podcast (14)
- # core-logic (42)
- # data-science (3)
- # datalevin (8)
- # datomic (76)
- # events (1)
- # figwheel-main (9)
- # fulcro (6)
- # helix (1)
- # holy-lambda (1)
- # honeysql (2)
- # jobs (2)
- # jobs-discuss (20)
- # leiningen (5)
- # lsp (87)
- # minecraft (11)
- # nextjournal (4)
- # off-topic (17)
- # practicalli (1)
- # reagent (22)
- # reitit (8)
- # releases (3)
- # rum (2)
- # shadow-cljs (18)
- # sql (11)
- # tools-build (5)
- # tools-deps (9)
- # xtdb (20)
is there a built-in way to do conditional routing in the frontend? right now, I either show the lobby or the active game, depending on if there is in fact an active game happening (using reagent), but for legacy reasons, they’re both routed to /play
.
I have
(defn lobby-or-game []
(if (get-in @app-state [:current-game :gameid])
gameboard
game-lobby))
(def routes
(rf/router
...
["/play" {:name :nav/lobby
:view lobby-or-game}]
...))
where gameboard
and game-lobby
are the two view functions that return hiccup, but this feels awkward/dirtyDoesn’t seem dirty to me. An alternative could be to use a controller to dispatch an event where you can check the app state and trigger an effect to redirect the user to lobby if needed
right now, for ease of use, the lobby is at /play
as well so if you’re in a game, you can’t see other games (which limits other legacy issues lol)
cool, thanks