This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-06
Channels
- # announcements (12)
- # babashka (34)
- # beginners (85)
- # calva (76)
- # cider (14)
- # clj-kondo (49)
- # cljs-dev (32)
- # clojure (418)
- # clojure-europe (3)
- # clojure-france (4)
- # clojure-italy (17)
- # clojure-losangeles (8)
- # clojure-nl (5)
- # clojure-norway (2)
- # clojure-spec (2)
- # clojure-uk (88)
- # clojuredesign-podcast (4)
- # clojurescript (49)
- # clojurex (75)
- # clr (2)
- # core-async (13)
- # cursive (6)
- # datomic (57)
- # duct (31)
- # emacs (6)
- # fulcro (25)
- # graalvm (67)
- # graphql (13)
- # hoplon (1)
- # java (6)
- # juxt (11)
- # kaocha (5)
- # keechma (2)
- # leiningen (16)
- # mount (1)
- # off-topic (19)
- # pathom (2)
- # pedestal (1)
- # re-frame (11)
- # reagent (21)
- # reitit (22)
- # rewrite-clj (1)
- # shadow-cljs (98)
- # spacemacs (5)
- # sql (16)
- # tools-deps (8)
- # vim (28)
- # xtdb (4)
Hi everyone!, I have defined a custom fx with
(rf/reg-fx :ws-send (fn [args]
(when args (apply chsk-send! args))))
then I use it in (rf/reg-event-fx :product.list/fetch-products
(fn [_ _]
{:ws-send (list [:products {:offset 0 :limit 20}] 2000 (fn [cb] (when cb (rf/dispatch [:product.list/set-products cb]))))}))
I'm very new to re-frame (and react as well). Do you normally just have the route set a key in the db which choose which page is shown?
you can, though the URL is a little special since you have to listen to changes in the location anyway, so I think reitit's example of just using a ratom makes sense, even for reframe: https://github.com/metosin/reitit/blob/master/examples/frontend/src/frontend/core.cljs
also note that in that example, they are just adding view components as data in the route, which is convenient
Reitit also has example of storing the current route in re-frame: https://github.com/metosin/reitit/blob/master/examples/frontend-re-frame/src/cljs/frontend_re_frame/core.cljs This can be useful in some cases, like if you have other event handlers which need to know what the current route is.