Fork me on GitHub

Anybody have re-frame running on ions?


@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.


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


@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

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


If you haven't seen them, both;t=9s and were great talks that might give you other ideas with that stack


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


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.


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


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.


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?


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


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?


@mateus.pimentel.w: Should be compiled back to a normal function in production (as long as you set up the dependencies properly based on )


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. )


@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.


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


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


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?


There's a timer example on - is that kind of what you are looking for?


Oh my god.


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




I've been there many times 🙂


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


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


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


No, not in the app-db at all.


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.


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.


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


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 for how to handle different local state like that.


Thanks, Shaun.


Hope it helps!