Is it possible to await for dispatch is finish

aha*_*sky 11 reactjs react-native redux redux-thunk

I have 2 actions, and I call from the first action to the second action .... and I need to wait until the second action is finished and only then continue with the action.

// first action
export const getDataFromAdmin = () => {
    return async (dispatch, getState) => {
        dispatch(getDeviceLocation());
        console.log('only after getDeviceLocation is finsih');
        AdminRepository.getDataFromAdminAndEnums(dispatch)
            .then(adminData => {
              //some code 
            })
            .catch(error => {
                console.log(`Splash Error = ${error.message}`);
            });
    };
};


//second action
export const getDeviceLocation = () => {
    return async dispatch => {
        dispatch({ type: actionsType.GET_DEVICE_LOCATION });
        LocationManager.getCurrentPosition()
            .then(location => {
         
                dispatch({ type: actionsType.GET_DEVICE_LOCATION_SUCCESS });
            })
            .catch(error => {
                dispatch({ type: actionsType.GET_DEVICE_LOCATION_ERROR, message: error.message });
            });
    };
};
Run Code Online (Sandbox Code Playgroud)

su_*_*iya 2

不,这是不可能的,因为分派一个动作就像触发动作一样,而动作只是调用中间件或减速器而已。该操作不会等待减速器或中间件完成。它只是调用并完成他的工作。