I'm using redux to manage my app state,and using Google map(or other map) to show my data.
I have a very complex UI and want to manage it with redux. But I have a question below:
- I have two components A and B, they are in separate parts, A is a button , B is a component with Google map in it as a inner property called "map"
- When Click A ,I want to trigger
map.panBy(-10,-20), the result is that center will be changed, but by executingpanBythere is an animation, in this case(-10, -20)is not the result, it's just offset, so save it(offset) on the store is not a good idea. What shoud I do? Solution I: using redux data flow, dispatch an action like{type:'panBy', payload: [-10, -20]}, and when component B get the data, executemap.panBy(-10,-20). --> -10, -20 are temporary params, store them is weird.Solution II: Eventbus, component A trigger event and component B subscribe it .Solution III: Exposemapto it's parent or to thewindowobject. --> weird too...
So, is there a common solution to resolve this?
Can I use redux middleware? But middleware DONOT know the map either.