I have the following initial state and slice objects. How do I add values to the hand array every second using dispatch? My intention is to have each dispatch be completed before the next one. I looked at createAsyncThunk but I wasn't clear on how to implement it on the same action repeatedly with a time interval.
const initialState = {
hand: [],
};
export const stateSlice = createSlice({
name: 'black',
initialState,
reducers: {
updateHand: (state, action) => {
state.hand = [...state.hand, action.payload]
}
}
});
Thanks.