Current section: Dynamic Promises 29 exercises
solution

Pending Flash

Loading solution

Transcript

00:00 All right, let's take care of this flash of pending state. You can control this a little bit if you come down here. So you could play around with the delay, like what if I want it to take 200 milliseconds? Then that's how long it's gonna take for each one of these. And so now it's not quite so much of a flash,

00:17 though it is kind of, it's a brief thing. What if I want it to be 100 milliseconds? Okay, so now it is a bit more of a flash. And then here are 10 milliseconds. That is definitely a flash, like yikes, pretty bad. So the point is that you don't actually get to control this very well because you don't know what the user's network conditions are

00:37 and so we want to have this in place for whatever those conditions are. So I'm going to rename this to isTransitionPending and then I'll have an isPending based on useSpendDelay. And we can configure this to be whatever we want.

00:53 I'm gonna put the delay and minDuration to 350, so delay will be 300, minDuration is 350. That's what Peter, the product manager, wanted. And now with that, we are totally done. So now I click on this. You'll notice it happens so fast

01:12 that we don't see any pending state. If I come down here and change this to be 350, now that is over our duration of 300. So we're gonna sit and we get that pending state, but you'll notice it doesn't instantly flash. So even though our delay is 300 milliseconds

01:30 and our total delay for getting the ship is 350, we're not flashing it for 50 milliseconds, we're showing it for an additional 300 milliseconds thereafter. So it is a better user experience, 100%, way better. So I'm happy with this. I hope you're happy with it too.

01:49 Feel free to futz around with this a little bit to see what the user experience is like now that we've got spend delay.