Since I am building multiple (it is five now, I expect more) applications I feel the need to build a library with reusable components. This are my thoughts and problems with the re-frame part.
Say, I have a reusable
contacts component, living in the (here simplified)
contacts namespace. The
contacts.api namespace has functions for managing the contacts data structure (mostly CRUD, like
contacts, …). Then I have
contacts.re-frame which defines subscriptions and events. These mostly just call
contacts.api functions with the contacts data structure from the app-db. There is also the
contacts.ui-components namespace which contains the react components.
chat application (or component) uses the
contacts component. Using the re-frame subscriptions and events is no problem. Using react components also fine. But I strugle how the
chat.api namespace should get access to
chat.api works on its own datastructure which it gets passed from
chat.re-frame, it has no access to the contacts datastructure and therefor can not call anything from
contacts.api. It seams, the functions from
chat.api need to also get the contacts datastructure passed and need to return it besides its own.
In the Java world I tackled such things with dependency injection, I am unsure how this should work in the world of immutability. Am I on the right path? Is there a better way to build this? Thank you for any suggestions or links.