why subscribe can not get action.I don't know whether the following is a good idea
listeners.slice().forEach(listener => listener())
//to
listeners.slice().forEach(listener => listener(action))
Subscribers should react to the new state, not to what happened.
This is important for ensuring consistency.
You can use custom middleware to get around it.
Please see:
https://github.com/rackt/redux/issues/347
https://github.com/rackt/redux/issues/580
In my case, the action is sent to the server after "dispatch" is done. The server has same Redux store as client and the action changes the server state to synchronize with client state.
In this case, it is convenient if "subscribe listener" is given the action parameter.
Of course, this can be achieved using middleware. But it may be better if this is a default way of "subscribe listener".
By preparing the same Redux store in server as well as in client, server-side state manipulation becomes same as client.
In this concept, the action is a state synchronizer which is transferred among all the connected client including the server.
This is exactly the use case for middleware.
Most helpful comment
Subscribers should react to the new state, not to what happened.
This is important for ensuring consistency.
You can use custom middleware to get around it.
Please see:
https://github.com/rackt/redux/issues/347
https://github.com/rackt/redux/issues/580