Fork me on GitHub

I’ve got a very simple setup

  (fn [coeffects _]
    (assoc coeffects :now (js/Date.))))

  [(re-frame/inject-cofx :now)]
  (fn [args _]
    (js/console.error args)
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 [],
 :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?


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


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


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

👍 10

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


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.


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


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.


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


Or is it normal to have both in one project?


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.


got it thanks