Fork me on GitHub
#re-frame
<
2021-07-29
>
currentoor00:07:46

I’ve got a very simple setup

(re-frame/reg-cofx
  :now
  (fn [coeffects _]
    (assoc coeffects :now (js/Date.))))

(re-frame/reg-event-db
  ::initialize-db
  [(re-frame/inject-cofx :now)]
  (fn [args _]
    (js/console.error args)
    db/default-db))
but for some reason that coeffect isn’t showing up in ::initialize-db in re-frisk, when I select this event, I can see this
{:event [:mutesync.inspect.electron.renderer.events/initialize-db],
 :effects {:db {:name "re-frame"}},
 :coeffects {:now #inst "2021-07-29T00:06:50.091-00:00"}}
but in the event handler the cofx map is empty, any ideas?

currentoor00:07:33

Oh I see I need to use reg-event-fx instead

currentoor00:07:59

funny how such obvious things can take so much time to figure out!

emccue01:07:13

@U09FEH8GN long threads about this written - but my general advice is to always use reg-event-fx

👍 10
emccue01:07:31

and only return :db and :fx as top level keys in the map you return

emccue01:07:48

prevents context switching issues like this one

Oliver George14:07:46

Anyone have a re-frame.core/debug equivalent for production. Something lighweight. Identifying paths in app-db which have changed due to event handler would probably be enough visibility to confirm intended/surprising behaviour.

p-himik14:07:18

debug could be used in production, if you want to find such paths for some reason. But what do you mean by "lightweight"?

Oliver George14:07:13

Debug output doesn’t render for me without devtools. Serialising could be cpu intensive.

Oliver George14:07:13

But maybe leveraging diff is an option

p-himik14:07:18

It doesn't serialize anything, no? It just sends the data as is to the console. If you want something specific, the debug code is just 20 lines of very simple code. Which indeed uses diff. So you can just copy and paste it into your own code base and log the results in the way you prefer.

currentoor21:07:14

Are re-frame-10x and re-frisk both solving the same problem?

currentoor21:07:29

Or is it normal to have both in one project?

sansarip18:07:41

I’ve personally only seen one or the other used, not both. And most the time, it was 10x being used. They seem to offer the same major insights e.g. viewing app-db, subscriptions, events, etc. with (minor) differences here and there e.g. frisk seems to offer a graph visualization of subs that 10x does not.

currentoor18:07:40

got it thanks