There are a couple of common problems with Re-frame subscriptions that I’d like to solve:
-
Because subscriptions are registered via keywords, the ClojureScript compiler does nothing to help check that we haven’t made a typo when subscribing.
-
We often need to use the same logic to access a value in the app DB in both a subscription and in events.
I’ve come up with the following structure. First we create the accessor function, which can be used by both the subscription and any events. (This of course implies that the namespace where we implement our events must refer to the namespace where we define our subscriptions.)