Fork me on GitHub
#re-frame
<
2019-11-06
>
Vachi13:11:36

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]))))})) 

Vachi13:11:30

but I'm getting a invalid event Exception from router.clj any idea?

Vachi13:11:57

nevermind, found the problem , it seems that sente needs namespaced keys as event id

donyorm19:11:08

What are people's opinions on routing libraries for re-frame?

isak19:11:03

i like this one the best: https://github.com/metosin/reitit

👍 4
donyorm19:11:32

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?

isak19:11:58

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

isak19:11:57

also note that in that example, they are just adding view components as data in the route, which is convenient

donyorm19:11:09

Ok that makes sense. Thanks!

juhoteperi19:11:32

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.

4