I have noticed that sometimes actions in Redux use return and others dispatch. I also noticed that dispatch is used when there is some async operation in that action function, like reading/posting from/to a database, but I don't understand why. Could anyone shed some light on the crucial difference. Why don't we use dispatch all the time for example, as in context API in React?
EDIT: I will add an example, that doesn't deal with the backend, so there is no async await cycle:
//with return
export const addLog = (log) => {
return{
type: ADD_LOG,
payload: log
}
}
//with dispatch
export const addLog = (log) => disptach => {
dispatch{
type: ADD_LOG,
payload: log
}
}
What's the difference between the two?