Fork me on GitHub
#re-frame
<
2018-12-05
>
kvlt00:12:02

Anybody have re-frame running on ions?

danielcompton02:12:01

@petr people from time to time talk about running re-frame on the server, but I don't think it is a very good fit.

danielcompton02:12:22

There's a thread on the re-frame GitHub repo about it if you're looking for more details

kvlt02:12:26

@danielcompton thanks for the reply. I figured as much. Would have just been convenient for deployment. I'll see if I can find the thread

Nick Stares14:12:58

Has anyone used pathom for traversing an app-db in re-frame?

👀 4
shaun-mahood15:12:16

It sounds like it's pretty tightly tied to Fulcro - but if you can get it working with re-frame that would be pretty awesome! I'm planning to look at it when I get a chance but not sure if I will attempt to use it with re-frame or not.

Nick Stares15:12:09

Yeah, I'm trying to figure out if it's a good philosophical fit for re-frame. We've had some annoyances traversing a big app-db before so thought it might be handy.

Nick Stares15:12:09

Yeah, I'm trying to figure out if it's a good philosophical fit for re-frame. We've had some annoyances traversing a big app-db before so thought it might be handy.

Nick Stares16:12:03

I should also say that we're using re-graph and lacina-pedestal so I'm wondering if it would complement or conflict with that

shaun-mahood16:12:44

If you haven't seen them, both https://www.youtube.com/watch?v=mgSSVTDZvkI&amp;t=9s and https://www.youtube.com/watch?v=EDojA_fahvM were great talks that might give you other ideas with that stack

hoopes16:12:09

in an event handler, is there any way to tell where the dispatched event came from?

mafcocinco16:12:06

I'm not sure if this is supported natively but IIRC an event can contain any arbitrary data from the dispatcher. You could add a :who field to the event to indicate where the event came from if it is relevant to the event handler.

hoopes16:12:07

that's true - my app is not big yet, so i can add that to the couple places that ship the evt

mafcocinco17:12:31

I would offer one word of caution: If you event handler needs to know where the event came from, it might be a code smell. That is not 100% true and I can't really say without having looked at the code but, generally speaking, I try and be agnostic as possible WRT my event handlers caring about who or what dispatched the event. Again, not saying it is wrong, just something to think about and maybe see if you can implement things in such a way that your event handlers do not need to know who is dispatching the event.

hoopes17:12:10

it was more for debugging - i know i'm getting this event, and it's doing the right thing, but where the hell is it coming from, and why?

hoopes17:12:12

i haven't dug super deep into the features yet though

Whiskas18:12:32

if i use fn-traced in all my events, will i have any problem in production? or the compiler transpile it to a normal function when we use it on production build?

shaun-mahood18:12:14

@mateus.pimentel.w: Should be compiled back to a normal function in production (as long as you set up the dependencies properly based on https://github.com/Day8/re-frame-debux/blob/master/README.md#two-libraries )

Whiskas18:12:59

should i use fn-traced on effects and co-effects too? ( I think that it is only for events, haha, but asking just in case. Probably not. )

shaun-mahood18:12:12

@mateus.pimentel.w: Try it and see what fits your application best - I over traced and under traced until I found the sweet spot for me. Some things I thought would be good to trace were totally overkill, other things I thought didn't need tracing ended up being the things I needed to troubleshoot.

Whiskas18:12:55

But it is possible to trace the code execution of effects?

mikethompson20:12:25

Nice to hear of people using fn-traced within re-frame-10x

jeaye22:12:31

When rendering timestamps to relative dates (`now`, 5m ago, etc), I run into a problem of the db not changing but me wanting to re-render, since time has changed. I'd like to @(subscribe [::refresh.event/ms 1000]) in my view to have it render at least every second, but implementing this subscription has me wondering how I can do it without touching the db. Yeah, I could update the db every 100ms or something to trigger the subscription to check if it should change, but that's just going to clog up my event queue and put junk I don't want in my db. In short, is there a way for me to make a reaction around an atom which changes via a JS timer so this can be accomplished without changing my event log and my db?

shaun-mahood22:12:34

There's a timer example on https://reagent-project.github.io/ - is that kind of what you are looking for?

jeaye22:12:23

Oh my god.

jeaye22:12:42

"make a reaction around an atom" => r/atom

jeaye22:12:48

:man-facepalming:

shaun-mahood22:12:21

I've been there many times 🙂

jeaye22:12:26

Thinking too much in terms of re-frame and not in terms of reagent. Thanks, @U054BUGT4.

jeaye22:12:33

So, would I need to use reg-sub-raw to marshal this r/atom into a subscription?

shaun-mahood22:12:07

Do you want it in your app-db at all, or just as an output that is independent?

jeaye22:12:53

No, not in the app-db at all.

jeaye22:12:13

Would be nice to be able to use subscribe for it, though, in the format I mentioned. That way it feels like all other subscriptions.

shaun-mahood22:12:31

Then you don't need to think in re-frame terms at all - modify that example to take what you need, and when you want to use it then grab the current value of the atom.

jeaye22:12:02

Yeah, I was just hoping I could. Sounds like I might need to just work with the r/atom directly though.

shaun-mahood22:12:21

Yeah - you can create the atom for the state and the underlying reagent component as part of your UI component. There are good examples in https://github.com/Day8/re-com for how to handle different local state like that.

jeaye22:12:11

Thanks, Shaun.

shaun-mahood22:12:23

Hope it helps!