I have a lot of
(re-frame/reg-event-db ...)
rolling around
Any reason against doing
(def db-events {:event1 handler1
:event2 handler2})
And then (map reg-event-db db-events)
Just for the sake of saving characters π
I do it sometimes. Only not map
but doseq
because map
is lazy.
The issue with such approach is that it would make it harder to selectively change interceptors.
Thank you, I don't have interceptors currently so didn't think about it
And BTW I don't do it when I have just regular event IDs with corresponding handlers - I just call reg-event-*
as usual in such cases.
But I always do it when I have roughly the same handler for a bunch of events. Then I iterate over event IDs with maybe some parameters that slightly alter how the handler works.
slightly unrelated but a little bit related, check out https://gitlab.com/nikperic/reframe-utils if you haven't, removes a modest amount of boilerplate
Interesting
I like the idea but donβt use it currently. One possible complication is code reloading. Does the code change trigger re-registering the event? Does re-frame throw a lot of re-register warnings?
All solvable
It doesn't affect code reloading at all.