Closed ssneilss closed 8 years ago
I see your point, but I don't see why the middleware is required. I would still have to have a switch
statement in socket.onmessage
because there will be cases with non-pure side effects of receiving an action outside of simply modifying the store.
Couldn't I just put the middleware directly in the socket code?
socket.onmessage = function(m) {
// parse data
// call other functions
const { event, ...options } = m
action = require(`.../actions/game.js`)[event]
store.dispatch(action(options))
}
I think that the way I specified above would work while the project is still small, but eventually we will need middleware. Wouldn't it be easier to use thunks instead of custom middleware?
I think redux-thunk is very good as well :)
I'm working on this.
Because you are implementing redux framework, the usage of "middlewares" will be super helpful for you to deal with actions
I think it might be better to write socket.onmessage part like:
somewhere in the codes...
message_middleware.js
also don't forget to include the middleware into store configuration (see #85 )