Current section: Optimistic UI 29 exercises
Problem

Multi-step Actions

Loading exercise

Transcript

00:00 Sometimes our actions are doing more than one thing. Now, you're probably looking at this, some of you, and you're like, shouldn't that be done with some sort of queuing system or something like that? And yeah, probably, but we 100% have situations where we're saying, OK, I've got to do this, and then I'm going to do that, and then I'm going to do this. And it would be nice to update the user as we're

00:19 processing all of those things. And with UseOptimistic, you can actually do that quite easily. So let's assume that this set message is coming from a UseOptimistic thing. Then we can say, hey, I'm creating my order, and now I'm creating the payment, and now we're almost done. And we can display those messages. And all of this works because even though we're

00:38 running inside of a transition, inside of this action, we can make state updates with UseOptimistic. So UseOptimistic is in just about Optimistic UI, and that's the point of this exercise step. So your job is to make it so that we have one message for while we're creating, and then another one while we're loading.

00:56 So let's get to it.