▸ Don’t build “React apps” — it should only be part of your architecture ▸ Separate concerns — React should just be your view layer ▸ Keep your core business logic outside of React components
a uni-directional data flow ▸ When your Redux store state changes, your React views respond with new data ▸ Removes business logic out of your React views ▸ Your UI becomes a state machine
architecture ▸ Doesn’t have an out of the box async story ▸ You need to build an architecture on top of Redux to handle async ▸ Good news is, Redux has a way to be extended
is in progress. Useful for telling the user to stand by or to keep other requests in sync ▸ Fulfilled: Operation is finished. Update the UI or do some other operation ▸ Rejected: Operation failed. Handle the failure in whatever way makes sense for your application
action and the moment it reaches the reducer. ▸ Uses currying to allow you to create custom dispatch functions (middleware) that are called sequentially in between dispatching and the reducer ▸ Essentially, you can hook into the dispatcher with a chain of functions
with Redux and build on top of that with middleware. ▸ We can use the Redux store to track the state of async operations, but middleware manages operation of async operations.
you to dispatch a function which will be called by redux- thunk middleware. ▸ redux-thunk will pass in dispatcher and getState functions so you can dispatch an action at the end of an async operation
redux promise middleware libraries are already FSA compliant. ▸ Promises are in the language and are built for async. ▸ Use pburtchaell/redux-promise-middleware. It’s the best one out there with good conventions.
Programing (FRP) is your thing, this is the library for you. ▸ It’s a good abstraction, but it doesn’t feel like it belongs in JavaScript. ▸ DSL is huge and confusing. ▸ Many really smart people love it so form your own opinion. ▸ However, don’t use with Redux.
Based on generators. ▸ That we’ve been using at HelloSign in production. ▸ Instead of dispatching Thunks, you create Sagas to gather all your Side Effects logic in a central place. ▸ This means application logic lives in 2 places: ▸ Reducers are responsible for handling state transitions between actions. ▸ Sagas are responsible for orchestrating complex/asynchronous operations.
Sagas are multiple workflows, each providing compensating actions for every step of the workflow where it can fail. ▸ You can think of Sagas as daemons, a long living process for orchestrating transactions and handling recovery from failures.
of your architecture. ▸ Turns your async code almost into a reducer ▸ You can find all your async code in one place ▸ Can cancel an async action ▸ Harder to ignore the handling of async states ▸ Because it’s generator based, you can write async code that looks like regular code ▸ No dependency injection or mocking/stubbing needed for testing