Closed nicobarray closed 6 years ago
After some test with the todo
example, it seems that removing the restart
action adds unfortunate behaviours:
dispatch(subscribe('todos'))
before the onOpen
call result in a double join -> leave -> join sequence and therefore two channel snapshots.To fix this, the router
middleware is now called before the channel
middleware that handles the internal subscription state AND the router
middleware no longer synchronously call next(action)
on internal actionTypes. There is no reason to have an exception here (cc @chabou if you see one here)
Ready to be merge for me 🐎 (tested on todo
and todomvc
examples)
Amazing job 🙏
This PR fixes #30 and contains the following changes to the public API:
createAqueduxClient
,aqueduxReducer
,wrapStoreReducer
aqueduxMiddleware
tocreateAquedux
This change is intended to simplify the use of aquedux-client to:
As a result the new api contains 2 methods and 5 action creators:
Internally the changes are as follow:
src/
folderconstants/actionTypes
have new action types for the client interaction (start, stop, restart)createAquedux
creates the client and return the 3 internal middlewares chained.createClient
implement a sockjs client with onopen, onclose, onmessage listeners. It also hooks listeners to our eventHub to communicate with the internal middlewares (onSend, onStop, onRestart, onStart). It auto starts the socket connection when invoked. The underlying createSocketClient is removed.index.js
exposes the public APImanagers/
contains the same managers as beforemiddlewares
contains the 3 internal middlewares:channel
middleware is in charge of subscribing and unsubscribing to channelsclient
middleware is in charge of converting redux actions to client eventsrouter
middleware is in charge of sending the appropriate action to the server and unpacking received actionsThis version uses our event hub extensively to decouple the dependency between the store and the client.
The
todo
andtodomvc
are updated to match this version.On the minor changes:
token
localStorage key is nowaquedux-jwt
to have less chance of colliding with the used localStorage keys.utils/index
module has 2 new functions to compose the channel names.redux-thunk
dep is removed.cc @chabou