Fork me on GitHub
#re-frame
<
2020-10-07
>
Oz13:10:34

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 πŸ˜…

p-himik13:10:47

I do it sometimes. Only not map but doseq because map is lazy.

πŸ‘ 3
p-himik13:10:17

The issue with such approach is that it would make it harder to selectively change interceptors.

πŸ‘ 3
Oz13:10:41

Thank you, I don't have interceptors currently so didn't think about it

p-himik13:10:29

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.

πŸ‘ 3
victorb14:10:38

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

πŸ‘ 3
Oz14:10:40

Interesting

Oliver George20:10:13

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?

p-himik20:10:03

It doesn't affect code reloading at all.