This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
so i have some components which need to trigger differently parameterized instances of the same api call, and update the app-db with the results. currently i have two separate pairs of call/receive handlers which do this, and the knowledge of how to derive the app-db path to store the results at is in those handlers. this is leading to a profusion of identical-apart-from-result-path-derivation handlers. i would like to reduce code duplication with a better abstraction, but i can't immediately see a good way. how are other people dealing with this ?
@mccraigmccraig: I’m not sure if I understand well, a code sample would be better, I think you have several options: 1) extract shared functionality into plain function and both handlers should call it with their particular parameters, or 2) register one handler which will have that parametrization encoded in its event parameters (you can have two helper functions for creating such events with a pre-baked parameter), or 3) use middleware which will deal with app-db path, then register two handlers using two instances of this parametrizable middleware, re-frames’s own path
middleware does something like this
@darwin’s right on here, you can pass custom parameters into a subscription, you don’t need to just dispatch [:event-1]
and [:event-2]
@hkjels: not being worked on. I lack the design gene.