Chapter 6. Handling complex side effects

 

This chapter covers

  • Looking again at redux-thunk
  • Introducing generators
  • Managing complex asynchronous operations with sagas

Eventually, you’re going to want to handle more complex series of events in response to a user interaction. Using what you’ve learned so far, how would you handle logging in a user? The requirements will vary from app to app, of course, but let’s consider what could be involved. Your application may need to verify login credentials, issue an authorization token, fetch user data, handle retries upon failure, and redirect upon success. What tools are at your disposal?

Up to now, we’ve explored thunks by way of the redux-thunk package as a way to handle side effects and asynchronous operations. Thunks have a friendly learning curve and are powerful enough to handle just about any use case you can throw at them. However, they aren’t the only game in town. In this chapter, we’ll revisit thunks, then introduce another paradigm for handling side effect complexity: Redux Sagas. By the end of the chapter, you’ll have at least one more tool in your state-management toolbelt.

6.1. What are side effects?

6.2. Revisiting thunks

6.3. Introducing sagas

6.4. What are generators?

6.5. Implementing sagas

6.6. Handling long-running processes

6.7. Exercise

6.8. Solution

6.9. Additional side-effect management strategies

Summary

sitemap