salsita / prism

React / Redux action composition made simple http://salsita.github.io/prism/
496 stars 24 forks source link

EnhanceComponent doesn't work with thunk middleware #84

Open dfedynich opened 7 years ago

dfedynich commented 7 years ago

Hey, team. As far as I know, EnhanceComponent makes monkey patching for dispatch method to allow wrapping dispatched actions. Here is the patch

const dispatch = (action) =>
        store.dispatch({
          ...action,
          type: wrapper(action.type)
        })

But how can we work with thunks, when a function is dispatched instead of an action? Could you provide a general solution to work with this kind of middleware? Do we need to change EnhanceComponent source code each time, when we want to support custom middleware?