Fork me on GitHub
#re-frame
<
2023-03-09
>
Loic03:03:56

Hi, is it bad practice to overwrite a reg-event-fx ? I have a common namespace with all the reg-event-fx that work on both my web and mobile frontend. Then a dedicated ns in web and a dedicated ns in mobile will require this common ns and add their client specific events on top of that However, there is one reg-event-fx in particular I would like to overwrite in the mobile ns. It works but give me warnings on the react native console, is this consider bad design?

p-himik09:03:28

If that event is not common for web and mobile, why is it in the common ns in the first place? I would simply put the calls to reg-event-fx with the same ID but for different platforms in their corresponding namespaces, eliminating the need for overriding. If that for some reason is not feasible, even overriding is somewhat fragile as things start to depend on ns loading order. An alternative to that would be a global interceptor that monitors incoming events and replaces that particular event with some other.

👍 2
Loic10:03:47

I see. I was thinking if for whatever reason, there were lots of frontends, it could act as a default event. I ended up having the reg-event-fx with same Id in both client namespaces as you mentioned.

👍 4
scarytom21:03:28

FYI: if anyone uses re-frame-10x, be aware that upgrading to the newest shadow-cljs (v. 2.22.0) will upset it. Details in the https://github.com/day8/re-frame-10x/issues/382 I just raised, and some discussion in the #shadow-cljs channel starting https://clojurians.slack.com/archives/C6N245JGG/p1678396300803269

🙏 4