thomasboyt / redux-happy-async

async state with less boilerplate
MIT License
29 stars 0 forks source link

Optimistic reducer updates? #8

Open thomasboyt opened 8 years ago

thomasboyt commented 8 years ago

currently the actions only hit the reducer when an action succeeds... doesn't work for optimistic updates. dunno what a solution for that looks like though. seems like you'd traditionally need a lot of boilerplate like

switch (action.type) {
  case COMPLETE_TODO:
    if (action.status === START) {
      return state.setIn(['todos', action.todoId, 'complete'], true);
    } else if (action.status === ERROR) {
      return state.setIn(['todos', action.todoId, 'complete'], false);
    }
  }
}

and ofc that only works for actions where you know how to "undo" them

thomasboyt commented 8 years ago

https://github.com/ForbesLindesay/redux-optimist