export const incrementIfOdd = (amount: number): AppThunk => (dispatch, getState) => { const currentValue = selectCount(getState()); if (currentValue % 2 === 1) { dispatch(incrementByAmount(amount)); } };
References
https://redux.js.org/usage/writing-logic-thunks
https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware