Search many forum but still confuse, redux is async or sync?? Realize this is a basic question but I had no luck finding the answer elsewhere. if any one know describe with examples.
2 Answers
Redux store only supports synchronous data flow (ref).
This is what you get by default with createStore().
Asynchronous middleware like redux-thunk or redux-promise wraps the store's dispatch() method and allows you to dispatch something other than actions, for example, functions or Promises. Any middleware you use can then interpret anything you dispatch, and in turn, can pass actions to the next middleware in the chain.
For example,
a Promise middleware can intercept Promises and dispatch a pair of begin/end actions asynchronously in response to each Promise.
Comments
Dispatching actions is synchronous in Redux.
Without middleware, Redux store only supports synchronous data flow. This is what you get by default with
createStore().
For asynchronous actions, you can use applyMiddleware(), for middlewares such as redux-thunk.