mattkrick / redux-optimistic-ui

a reducer enhancer to enable type-agnostic optimistic updates
MIT License
693 stars 36 forks source link

Does it work with redux-thunk ? #24

Closed moimael closed 7 years ago

moimael commented 7 years ago

Hi,

I'm implementing redux-optimistic-ui in our webapp and it works well for most cases. But I noticed that when I try to use it with a thunk instead of a classic action, nothing happens. Any pointers ?

Thanks !

moimael commented 7 years ago

Ok so the middleware needs to be modified to work with redux-thunk. I added

  if (typeof action === 'function') {
    return action(store.dispatch, store.getState);
  }

But I'm not sure I the revert/commit stuff still works by doing this. It would be awesome to have an example of the middleware modified to work with thunk in the documentation :)

mattkrick commented 7 years ago

is your thunk middleware running before the middleware you write for this?

moimael commented 7 years ago

Ah no it wasn't, it seems to work now. Thanks !