Fork me on GitHub
#re-frame
<
2018-04-25
>
Bravi09:04:41

hi everyone. a quick question - how do I test my event handlers? for example, if I have

(rf/reg-event-fx
   :do-something
   (fn [cofx [_ item]]
     {:db ...}))
should I extract this anonymous function from there instead and have
(ref/reg-event-fx :do-something something-handler)
and then simply test something-handler normally?

Bravi09:04:17

or is there a re-frame way of testing this?

danielneal09:04:34

You can use https://github.com/Day8/re-frame-test for testing reframe subscriptions and events

😀 8
curlyfry10:04:02

@bravilogy The version with extracting the fn and unit testning it is common too

timo11:04:09

@curlyfry Hi there, I usually try to split my event-handlers for testing but how would I use fn-traced from reframe-10x with it? (sorry...beginner)

curlyfry11:04:04

There is a defn-traced as well! 🙂

timo11:04:18

great! thanks!

shakdwipeea14:04:58

Hi guys, I was trying https://github.com/Day8/re-frame-10x . But ctrl-h opens the <chrome://history> for me. I am using ubuntu. Is there a workaround ?

shakdwipeea14:04:11

I think there could be another issue here with my setup here main is not being called automatically.

shakdwipeea14:04:52

I got the reframe dashboard working. 🏁

kasuko17:04:13

I am having dependency issues with Global Interceptors, so if I want to define an interceptor that is run for all event handlers as described in https://github.com/Day8/re-frame/blob/master/docs/FAQs/GlobalInterceptors.md I have to refer to the interceptor in the re-frame namespace. This prevents me from using any re-frame in the interceptor itself (e.g. I can't dispatch events) unless I define the interceptor directly in my re-frame namespace., which is not ideal. Has anyone figured out a way to solve this? I'm leaning towards a global interceptor "registry" like all the other re-frame concepts to solve this issue.

shaun-mahood17:04:37

My understanding is that your my-reg-event-db can be put into a project util file (or something along those lines), then you refer to your util file to use it from the rest of your project. re-frame shouldn't need to depend on your file at all.

kasuko14:04:55

Ah I see, I unfortunately extended more of re-frame in to the same namespace as the util file, so I don't import both "re-frame.core" and "my-app.utils" everywhere, I just import "my-app.re-frame"

kasuko14:04:03

So this most likely is just a me problem :S

aaelony17:04:36

good morning, I want to issue an sql query to mysql via re-frame. I've done this in clojure via jdbc and have read this doc (https://github.com/Day8/re-frame/blob/master/docs/Subscribing-To-External-Data.md) but wondering what people normally do for the db connection, i.e. is it done in clojure with jdbc (I've done that many times before) or in clojurescript (never done that before... is there a library I need?) Seeking an example, if possible. Thanks

aaelony17:04:05

e.g. how would issue-items-query! connect to mysql (over jdbc? in cljs?)

aaelony18:04:57

looks like I'll revert to querying via jdbc on the server via a route then...

shaun-mahood18:04:15

@aaelony: You still need a back-end to talk to the database, and then you would communicate with that in a similar way to any other javascript client/server application. I have a REST based service running that I talk to using event handlers (described a bit in https://github.com/Day8/re-frame/blob/master/docs/Subscribing-To-External-Data.md#the-alternative-approach) and it works pretty well (my eventual goal is to use something like https://github.com/drapanjanas/pneumatic-tubes to make things a little more seamless though).

aaelony18:04:23

I just need to figure out how the plumbing from clojure to cljs works once the server gets the data then I guess. Thanks @shaun-mahood

aaelony21:04:12

Another strange question... If I do lein new re-frame myapp +10x +cider +handler +garden +routes, then do lein repl, get the prompt, then in a separate terminal do lein figwheel dev, when everything connects I get the "Hello from re-frame. This is the Home Page" in red color. However, if instead of the lein repl step, I do lein garden once, then lein figwheel dev, then the "Hello from re-frame. This is the Home Page" is *not in red color*. I'm using Chrome. Is that weird?