Fork me on GitHub
#re-frame
<
2016-09-27
>
vikeri08:09:21

A question about spec and re-frame. I think that it is quite useful to test that my subscriptions and handlers are conforming to a spec. Would it be feasible to add a meta-data key to subscriptions and handlers that specified input, and for subscriptions, output specs? Then one could 1 Instrument this in development 2 Run tests on each subscription in a test suite 3 Do generative testing (generating handler vectors) I’ll add an issue with this if it would be worth considering

jstaffans08:09:37

@vikeri: or maybe extend re-frame with something like fdef, but for subscriptions/handlers?

vikeri08:09:13

@jstaffans Yes, that is definitely also an option

lwhorton15:09:40

Has anyone come up with an error-capture/reporting interceptor, or how we’re supposed to handle that in 0.8? I see https://github.com/Day8/re-frame/issues/231 listed, but no responses so far.

lwhorton15:09:33

e.g. the pattern I want is “try X; catch E; report E to somewhere else”, but that becomes harder now that interceptors do the actual invoking of the handler function somewhere else, as opposed to the previous user-land chain-of-handler-invocations, where try/catch was easy

andre15:09:15

I didn't see this, when I started re-frisk, but definitely imagined exactly the same functionality

samueldev15:09:59

hey party people!

samueldev15:09:12

where are these built-in interceptors located?

samueldev15:09:19

i can't find trim-event anywhere in the re-frame 0.8.0 source

samueldev15:09:20

NVM. I didn't read. it's trim-v 😛

samueldev15:09:04

Unrelated: any way to get rid of this warning? https://puu.sh/rpDEg/8ad233c0b1.png

samueldev15:09:09

I know it's react complaining

samueldev15:09:14

JW if there's a workaround

lwhorton15:09:04

why do you have that attribute on the input tag?

samueldev15:09:18

I'm just working off the examples

samueldev15:09:25

they have it structured like this

lwhorton15:09:09

well, its hard to give any more help without any more reasoning behind why that might be there. I would just remove it and use a standard form :onSubmit, or maybe they wanted a button :onClick? hard to say.

lwhorton15:09:04

ah, [input {:on-save}] is not [:input {:on-save}]

lwhorton15:09:22

input (not keyword) is a custom element defined somewhere else that accepts :on-save as a prop

lwhorton15:09:47

whereas :input is a reagent keyword representing a standard html input tag

johanatan16:09:44

Hi, is re-frame 0.7.0 compatible with reagent 0.6.0 ?

samueldev17:09:16

I'm having trouble debugging one of my event handlers; it's logging out Handling re-frame event: ["asdf"]

samueldev17:09:30

shouldn't it be giving me.... Handling re-frame event: [:event-name "asdf"]

samueldev17:09:08

its hitting my correct handler but the db isn't updating is all

samueldev17:09:21

(reg-event-db
 :username-entered
 [trim-v debug]
 (fn [db [username]]
   (.log js/console "---> USERNAME ENTERED" username)
   (assoc db :username username)))

mikethompson19:09:19

@samueldev trim-v quite literally removes the 1st element of the event vector. And it is running "before" debug.

mikethompson19:09:59

You could always make the interceptors vector be [debug trim-v]

mikethompson19:09:10

(ie. reversed)

mikethompson19:09:46

That way debug will be logging the event before trim-v alters it

samueldev19:09:46

Gotcha, that fixed that

samueldev19:09:06

But I'm still getting no app db changes triggered by... even though my handler is pretty plain:

samueldev19:09:08

(reg-event-db
 :username-entered
 [debug trim-v]
 (fn [db [username]]
   (.log js/console "USERNAME SET" username)
   (assoc db :username username)))

samueldev19:09:37

@mikethompson able to point me in the direction of any debugging steps RE above?

mikethompson19:09:05

@samueldev it appears your old db is testing = to your old db

mikethompson20:09:14

@johanatan yes, re-frame 0.7.0 is compatible with reagent 0.6.0

mikethompson20:09:06

@andre I'd very much like to add an intrumenting interface to re-frame. One which would allow a piece of code to be told when certain events in re-frame happen. For example "starting to handle event [:a :b]". Running subscription [:get-user 42] Then, this code could build up a data structure which captures this instrumentation data. Which itself could then be shown via something like data-frisk.

mikethompson20:09:30

Obviously the code which is capturing the instrumentation data doesn't have to simply record it (otherwise good old console is good enough) but instead can build up a custom data structure.

johanatan20:09:05

@mikethompson: okay, thanks. Do you know if both will work with the latest version of React?

johanatan20:09:42

i.e., if I use :exclusions to prevent them bringing in React and then manually bring in the latest version myself

mikethompson20:09:59

re-frame doesn't depend directly on React, so the question is more if Reagent 0.6.0 will work with the latest React, and the answer to that is yes

rui.yang23:09:12

wonder if anyone got issues like: dispatching will invoke handler twice in dev, but not in prod cljsbuild?

rui.yang23:09:42

tried to do git bisect to find out what change caused it. no luck