Open Buggytheclown opened 3 years ago
Hi, nice work, checked a few packages for optimistic updates and i think that redux-optimistic-ui is the best! But i have a few point before we can start using it.
combineReducers({ counter: optimistic(counter), currency: currency, })
I don't want 'SET_CURRENCY ' action to trigger "@@optimist: Possible memory leak detected."
I want to have the same history after 'SET_CURRENCY' action
history
test('ignore action with no effect for optimistic reducer', t => { const enhancedReducer = optimistic(rootReducer); const begin0 = makeAction('INC', BEGIN, 0); const nonOpt0 = {type: 'SET_CURRENCY'}; const state1 = enhancedReducer(undefined, begin0); const actual = enhancedReducer(state1, nonOpt0); const expected = { beforeState: {counter: 0}, history: [begin0], current: {counter: 1} }; t.deepEqual(actual, expected); });
Before we will add action to the history we can check if it affect our state:
const nextState = reducer(state.current, action); if(type !== COMMIT && type !== REVERT && nextState === state.current) { return state; }
Hi, nice work, checked a few packages for optimistic updates and i think that redux-optimistic-ui is the best! But i have a few point before we can start using it.
I don't want 'SET_CURRENCY ' action to trigger "@@optimist: Possible memory leak detected."
I want to have the same
history
after 'SET_CURRENCY' actionBefore we will add action to the history we can check if it affect our state: