Check out a free preview of the full Advanced State Management in React (feat. Redux and MobX) course:
The "Sagas Exercise: Offices and Dragons" Lesson is part of the full, Advanced State Management in React (feat. Redux and MobX) course featured in this preview video. Here's what you'd learn in this lesson:

More practice using Sagas for asynchronous state management.

Get Unlimited Access Now

Transcript from the "Sagas Exercise: Offices and Dragons" Lesson

[00:00:01]
>> Steve Kinney: Earlier we took a look at that video and we had that little like random music generator with random stats, and that's asynchronism. It's pulling from an API and we hit the request new friend button and that theoretically should trigger, let's say, a request new friend action. Then we would want to setup a saga that's going to receive those, trigger the HX request.

[00:00:29] We have a helper called API.request new friend. Fire that off very similar to what we just did in without all the other thunk stuff in place. And then when that happens, we want to add the user to the page. So effectively, the flow that we wanna implement here is the user clicks a button.

[00:00:47] We dispatch a request action, that triggers the server to make the API call. And then from there, when we hear back from the server, we can dispatch the action to the data to update the user interface with the new With a new implementation.