Description
Is your feature request related to a problem? Please describe.
useFluxible
hook is not as expressive asconnectToStore
.- There is a lack of documentation and clear way to "subscribe" to values in store when using hooks.
- The hook can be optimized to rerender exactly when StoreA out of [StoreA, StoreB] changes
Describe the solution you'd like
const locationStore = useStore('UserGpsLocationStore')
which would trigger a rerender on user Gps location change. The Gps location value is used in multiple components (similar as context)
- MapWithTracking
- A "Complex-Event-Processing" module to determine if the user is currently at a designated location
- A view to indicate where the user is currently at
Before, the user's GPS location can be read from the context, but current implementation of fluxible-addons-react no longer supports legacy react Context API. It seems that the better way is to implement auseStore
hook with a more fine-grained control over the data.
Describe alternatives you've considered
1.
Using current connectToStore
HOC solves the problem (but less elegantly).
A wrapper has to be implemented on top of a hook component connectToStore(<HookBasedComponent />, [StoreA, StoreB])
Downside:
- Does not take advantage of React hook's optimization. Component may be frequently updated on props change.
- Looks more complicated than a hook-based component and more difficult for IDE to refactor and track type hints
Using current useFluxible
hook
I am not very clear on the behaviour of this hook (whether it would trigger a rerender on Store change). Either way, it seems that a more fine-grained hook would be better.
I am considering implementing this hook, but hope to get some advice and feedback from the community first.