itaylor / redux-socket.io

An opinionated connector between socket.io and redux
410 stars 53 forks source link

Do not evaluate thunks. #17

Closed livebit closed 7 years ago

livebit commented 8 years ago

Using thunk middleware action creator can return a function instead of an action object (Async Action Creators: http://redux.js.org/docs/advanced/AsyncActions.html).

itaylor commented 8 years ago

Hi @livebit, thanks for the PR.

Right now, redux-socket.io makes the assumption that you've already handled your non-action dispatches (thunks, promises, whatever) further up in the middleware chain. I'm a bit inclined to keep it that way so I don't have to write code to detect all the non-action things that might be dispatched.

Is there a particular reason that you need the redux-thunk to come after redux-socket.io in the middleware chain that I'm not familiar with?

livebit commented 8 years ago

Hi @itaylor, I was little suprised that changing middleware chain order caused error. In my humble opinion as far as redux-socket.io handles only actions that are objects with property type everything else should be ignored instead of throwing error. I guess something like this would be even better solution: if ( typeof action !== 'object' || !action.hasOwnProperty('type') ) return false

itaylor commented 7 years ago

We resolved this with PR#25