I'm attempting to move my redux store towards the redux toolkit. Favourably I'd like to put them all into createSlice.
Before I had many of those kind of dispatches:
export const resetSelection = () => (dispatch, getState) => {
dispatch(clearSelection()); # clears current selection
dispatch(showLoader()); # shows global loading spinner
dispatch(fetchSelection()); # fetching selection with no filters applied
};
NOTE: showLoader is part of a different reducer.
Or:
export const loadDataTypes = () => async (dispatch) => {
dispatch(loadingDataTypes());
const data = await genericJsonFetch(GET_DATA_TYPES);
dispatch(setDataTypes(data));
dispatch(loadingDataTypes());
};
How would I do this with the redux toolkit, as I can't trigger a dispatch within a reducer obviously?