This is a library for using Redux to manage state for self-contained apps in a Micro-Frontend architecture. Each self-contained isolated app can have its own isolated and decoupled Redux store. The componentized stores interact with a global store for enabling cross-application communication.
MIT License
344
stars
64
forks
source link
Support exposing derived state from an app that partner apps can consume. #38
The beauty of this library is that you can combine with multiple redux states and they can be able to lazy loaded and registered when appropriate. By being able to subscribe to a partner state, we get the ability to get the latest state from a partner app but the problem is that Redux ideally saved the smallest amount of data in the store, and use libraries like reselect can do computations and compute derived state. Making getting derived state from partner apps not possible.
If the GlobalStore was able to expose derived state APIs then the partner apps could listen to state changes, but also get derived state without knowing the structure of the partner state. Otherwise, listening to partner state changes would require another partner app to grab the state and massage the data as needed - while this does work, it forces apps to be coupled and require to understand the structure of each others state, which is not desired.
I've tried chunking the selectors from partner apps, and lazy loading; however, reselect isn't meant to lazy load selectors, so it is rather difficult. Furthermore, it makes it hard to truly decouple apps.
The beauty of this library is that you can combine with multiple redux states and they can be able to lazy loaded and registered when appropriate. By being able to subscribe to a partner state, we get the ability to get the latest state from a partner app but the problem is that Redux ideally saved the smallest amount of data in the store, and use libraries like reselect can do computations and compute derived state. Making getting derived state from partner apps not possible.
If the GlobalStore was able to expose derived state APIs then the partner apps could listen to state changes, but also get derived state without knowing the structure of the partner state. Otherwise, listening to partner state changes would require another partner app to grab the state and massage the data as needed - while this does work, it forces apps to be coupled and require to understand the structure of each others state, which is not desired.
I've tried chunking the selectors from partner apps, and lazy loading; however,
reselect
isn't meant to lazy load selectors, so it is rather difficult. Furthermore, it makes it hard to truly decouple apps.I have submitted a PR to implement this feature here: https://github.com/microsoft/redux-micro-frontend/pull/39
Thank you so much for such a wonderful library! :)