This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-31
Channels
- # announcements (1)
- # aws (4)
- # babashka (40)
- # beginners (89)
- # calva (13)
- # cider (3)
- # clj-kondo (36)
- # cljdoc (16)
- # clojure (74)
- # clojure-boston (1)
- # clojure-dev (7)
- # clojure-europe (30)
- # clojure-new-zealand (1)
- # clojure-nl (17)
- # clojure-uk (5)
- # clojurescript (16)
- # core-async (9)
- # cursive (16)
- # datahike (3)
- # datalog (6)
- # datascript (7)
- # datomic (15)
- # emacs (38)
- # events (2)
- # figwheel-main (3)
- # fulcro (6)
- # google-cloud (18)
- # graalvm (6)
- # gratitude (1)
- # honeysql (1)
- # introduce-yourself (1)
- # jobs (1)
- # leiningen (5)
- # lsp (6)
- # malli (11)
- # meander (2)
- # off-topic (4)
- # re-frame (6)
- # reitit (8)
- # releases (2)
- # remote-jobs (3)
- # reveal (4)
- # shadow-cljs (200)
- # sql (8)
- # tools-deps (16)
Hi, I'm trying to tie re-frame with reitit. I'm wondering what is the correct pattern when trying to navigate to a route like /item/:id to display a dedicated view of a single item (where that item is then fetched via an API call). If I used reitit on backend, I'd just use "/item/:id" as my route and call the controller with a parameter, and render a page. I've looked at the frontend-re-frame example but it doesn't do what I need and I'm having trouble imagining how this should work together. Would appreciate any pointers 🙂
Views should not care about the routes at all. The should care about the data in your app-db, which they get via subscriptions. Navigating to a new route should dispatch some event(s) that end up changing app-db. The views will then simply react to the new data. You might want take a look at kee-frame BTW - it does a few things for you, quite handy.
That makes sense, thanks. Kind of what I imagined, though I still need to think how exactly to implement this.
you want an event listener from rfe to dispatch an event when the history changes. like this
(defn start-router!
[]
(rfe/start! (rtf/router routes/generated)
(fn [route-data] (rf/dispatch [:set-route route-data]))
{:use-fragment true}))