Current section: Session Storage 6 exercises

Efficiently Removing Toast Messages with Flash API

Loading solution


00:00 So this one's a pretty quick one. We just need to switch our get call that we did right here, or our set call, to flash. And now the next time that a get is called for toast, it will automatically be unset. So let's come over here to our root where we are doing that get call,

00:17 and we can remove the unset. And that's it. We do still need to set the cookie. The browser needs to be made aware of the change in this session storage. But that's it. So I can come over here, hit delete, and that gets deleted. And then if I refresh the page, that is gone. That's

00:35 out of my cookie. So that's it. It's deleted. I refresh, it's gone. And we didn't have to worry about unset. And this is just such a common pattern that there's an API for it. So that's flash.