re-frame 2025-12-03

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?

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

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

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.

Should be okay to return nil from the handler fn.

👍 1