Fork me on GitHub
#reagent
<
2018-04-20
>
hkjels08:04:11

How do you handle modifying the inner-state of a type-3 component by a keyboard-event that is registered on component-did-mount?

javi10:04:24

where is the state that keyboard-event is modifying? in a r/atom local to the component?

lilactown18:04:14

is it discouraged to use a reagent atom similar to a normal atom (e.g. derefing inside of a go-loop?)

justinlee18:04:31

you can use it however you want, but the observer code only runs during the evaluation of the render function

justinlee18:04:05

so if you do something async, like a go loop, the deref will probably happen outside of the render evaluation and the observer code won’t work

justinlee18:04:38

if you are mutating the ratom and you just want updates to happen, you can do that anywhere. it is likely that you’ll want to do that in a go block if you are using cljs-http, for exmaple

lilactown18:04:39

that's fine. in my case, I don't need the observer behavior

lilactown18:04:05

inside of the view, anyway

lilactown18:04:20

I'm trying to figure out how to do server rendering with stateful stuff 😬

justinlee18:04:45

good luck 🙂

lilactown18:04:03

that seems to be what I'm getting from the various issues & blog posts I've read 😅

justinlee18:04:43

it’s just a relatively new technique. not that solid on js stacks afaict. it’s the kind of thing where small user base is a disadvantage

lilactown18:04:12

yeah. I've had simple SSR working for my team for awhile, but trying to figure out how to handle data fetching in a component-y way

lilactown18:04:41

I basically want something akin to apollo/relay w.r.t. how they do SSR

justinlee18:04:17

is apollo the thing that spun out of meteor?

lilactown18:04:32

I think so, yeah. it's a framework for working with GraphQL & React

lilactown18:04:28

right now I'm fumbling my way through figuring out re-frame and hacking on it to see if I can e.g. isolate the app-db per-request, dispatch any data-fetching events/effects, and wait for data to finish loading before rendering the component tree for reals

justinlee18:04:00

i’ve so far avoided re-frame.

lilactown18:04:27

it was re-frame, some other framework or roll my own. it seems like re-frame has quite a following so I'm trying that out first

justinlee18:04:50

i am now suspicious about things that introduce too many abstractions and terms

lilactown18:04:04

I might try out cannibalizing om.next's query stuff to do this instead

justinlee18:04:11

it’s probably great, but i feel if i just exercise some discipline i can do without

justinlee18:04:30

but sometimes i wonder if i’m missing out

gadfly36123:04:53

@lee.justin.m I was in the same boat as you regarding re-frame and discipline ... up until recently. I think what you can gain from re-frame, even if you are already disciplined, is stuff like re-frame-10x. The tooling around re-frame can get pretty great over time, and I am jealous that I don't get to use those goodies yet 😂

😂 4
👍 8
reefersleep13:04:15

I was thinking the exact same thing. The conventions that people build up around re-frame are also nice to lean against when in doubt, and the chatter here, even. Nobody will be discussing your custom solution; with re-frame, that mindshare is free and includes free further development of the library.

reefersleep13:04:05

We use a custom solution at work, and I really think we'd have much to gain from using re-frame instead.

👍 8
reefersleep13:04:15

I was thinking the exact same thing. The conventions that people build up around re-frame are also nice to lean against when in doubt, and the chatter here, even. Nobody will be discussing your custom solution; with re-frame, that mindshare is free and includes free further development of the library.