re-frame

Ryan 2025-12-03T15:02:28.925719Z

what’s best practice for an event handler that doesn’t need to.. do anything? Particularly the success-event handler of an ajax call that returned no novel data.. like do I return an empty map? nil?

rgm 2025-12-03T16:12:05.544309Z

I'm not sure if it's best practice, but I've used (rf/reg-event-fx ::my-event (fn [_ _])) just fine for a long time. I noticed re-frame/async-flow-fx provides a no-op handler for when you need to coordinate, which is basically this pattern: https://github.com/day8/re-frame-async-flow-fx/blob/14a429913009ac9105524045f4f64d700c820173/src/day8/re_frame/async_flow_fx.cljs#L227-L232

👍 1
Ryan 2025-12-03T16:13:26.743039Z

Thanks, I just realized I was essentially returning {:db db} with an unchanged db, and figured thats at least superficially inefficient.

rgm 2025-12-03T16:17:12.850179Z

yeah, I guess by the book it would be, by one unnecessary destructure plus one new arraymap allocation. Conversely, at least my supposed no-op handlers usually don't stay that way for long, so plumbing in for the near future seems fine to me too.

Ryan 2025-12-03T16:17:43.684589Z

yeah right on

Kimo 2025-12-03T17:18:30.563549Z

Should be okay to return nil from the handler fn.

👍 1