I have a project that use redux-toolkit and redux-saga it is working fine now. but now i have some question do I need to use redux-saga.
yield all([
takeEvery<any>(boardAcctions.addWidget.type, updateWidgetUI),
takeEvery<any>(boardAcctions.moveWidget.type, updateWidgetUI),
takeEvery<any>(boardAcctions.updateWidgetConfig.type, updateWidgetUI),
takeEvery<any>(boardAcctions.removeWidget.type, updateWidgetUI),
])
yield put(loginActions.updateUser(userdata))
yield put(dashboardAction.updateBoard(dashboarData))
but on redux-toolkit with function createAsyncThunk(). I can't dispatch another action. even on extra reduces it just only a reducer and I think dispatch another action inside that is not illegal
how do I do that without redux-saga?
Thank
Of course you can dispatch other actions from within createAsyncThunk
.
import { createAsyncThunk } from '@reduxjs/toolkit'
const fetchUserById = createAsyncThunk(
'users/fetchByIdStatus',
async (userId, { dispatch }) => {
dispatch(someOtherAction())
}
)