Redux time travel
Use effects in UI component directly
F8 2014 (Facebook)
What Redux Toolkit done for us
So... How can we eliminate the side effects in Redux reducers?
Redux Middleware can do this!
Let's start from a simple log function...
Log before & after dispatching an action
DRY: don't repeat yourself
Monkeypatch: I'm too lazy to import this function every time!
We can have many patches
Remove monkeypatch: pass the next for me plz!
You are able to write a redux middleware!
Side Effects Management
"thunks" are a pattern of writing functions with logic inside that can interact with a Redux store's dispatch and getState methods.
Can be synchronize or asynchronize function
How do we call the API?
Generator function yields Effects (Promise-like objects)
Yield an object and let middleware execute
Factory functions creating Effects
take: Take specific actions from middleware (blocking).
call: Send a blocking call request to middleware.
put: Send a
store.dispatchrequest to middleware (blocking).
fork: Send a non-blocking call request to middleware.
takeEvery: a high-level API built using take and fork.
takeLatest: a high-level API built using take, fork and cancel.
take, .... Register saga worker and listen on specific action type.
call, put, ....Run jobs defined in worker function.