Fork me on GitHub
#re-frame
<
2016-09-05
>
shaun-mahood00:09:01

@mikethompson: Ok thanks, I’m going to have to think about this a bit more in the context of things I’ve built.

am-a_metail15:09:12

@mikethompson - how rigidly do you stick to the stock file structure for each "panel"? I find cljs programmers quite keen to stuff as much as possible into single files rather than splitting them out

am-a_metail15:09:30

Personally I don't like files longer than 100 -150 lines or so

mikethompson15:09:15

We are pretty rigid about it. When I show up in a directory, and I see db.cljs or events.cljs I already know what's in them. I know where to look.

mikethompson15:09:16

If I'm new to the app, I go sniffing in db.cljs first, getting a feel for the Schema (the information model), from there i can venture out.

am-a_metail15:09:29

hmm - would folders with matching name be incredibly hideous for say, views or events?

am-a_metail15:09:47

i.e views/foo.cljs views/bar/cljs

am-a_metail15:09:54

Or would you then be approaching a new panel?

danielcompton21:09:37

@am-a_metail we do src/app_name/panel1/events.cljs, src/app_name/panel1/db.cljs, src/app_name/panel2/events.cljs, e.t.c.

dpsutton22:09:04

what's the best way to dispatch the value of a text box on blur?

dpsutton23:09:27

i've found a way. not sure if its great

dpsutton23:09:30

once thing conceptually strange to me is the re-frame tutorial makes quite a bit out of reaction but it is nowhere in the template and doesn't seem to be in core any longer

curlyfry23:09:37

@dpsutton Was it something like

(defn target-value [event]
  (-> event .-target .-value))

[:textarea {:on-blur #(dispatch [:blur-text (target-value %)])}]
?

dpsutton23:09:26

yeah basically

curlyfry23:09:45

I'd say that's "how you do it"

dpsutton23:09:23

fair enough

dpsutton23:09:49

do you ever use reaction? The docs seem to make a big deal out of it whereas it seems nowhere exposed to the user

curlyfry23:09:08

@dpsutton I think the reaction stuff in the tutorial is partly because it emphasizes how re-frame is implemented

dpsutton23:09:29

made me nervous i wasn't doing it correctly

curlyfry23:09:47

Pre 0.8.0 you have to use reaction in your subscriptions, but not anymore thanks to reg-sub

shaun-mahood23:09:55

@dpsutton: In v0.8.0, reactions are built right into your reg-sub calls - they're still there under the hood, you just don't have to write them manually.

shaun-mahood23:09:06

Part of it is a factor of the docs being written when it was still required and not being updated perfectly, but the concept is still pretty fundamental to how it all works.

dpsutton23:09:31

I was reading this and making sure i understood its implications and couldn't figure out who to do it and what I should take form it

dpsutton23:09:45

As now it seems reg-sub takes an subscription and a function which dictates what value is watched

shaun-mahood23:09:57

@dpsutton: if you compare reg-sub with reg-sub-raw you can see the difference in how they work - reg-sub-raw is the same as the old version.

dpsutton23:09:08

ah, and reaction is a reagent concept

dpsutton23:09:17

i was looking in reframe for that

dpsutton23:09:13

one last question for the night. What's the best way to have one event trigger 4 others?

dpsutton23:09:25

a single dispatch then causes 4 things?

shaun-mahood23:09:46

@dpsutton: Can you give an example of what you’re trying to do?

dpsutton23:09:48

Do you dispatch from reg-event-fx?

dpsutton23:09:11

Currently, when you click on a button, it hits an api call for an invoice

dpsutton23:09:16

but I actually need it to hit 4

dpsutton23:09:41

can i have it populate 4 tables from four sources with a single dispatch?

dpsutton23:09:45

or am i thinking about it wrong?

dpsutton23:09:52

But i need 4 of those actually

dpsutton23:09:14

and "you're doing it wrong" is a totally acceptable answer

shaun-mahood23:09:09

Hmm… let me think about it for a second - you’re doing it wrong doesn’t work well if you can’t change the API.

dpsutton23:09:02

I'd love if i could create a stream of urls along with where in the app-db to put it

dpsutton23:09:15

but i'm not sure where in the application to treat things like streams