Remember to Check for Done

John Lindquist
InstructorJohn Lindquist

Share this video with your friends

Send Tweet
Published 4 years ago
Updated 3 years ago

It's easy to forget to account for "done" when you're not working with sequences or any sort of completion. But it's important to remember that all timers have an end which will push out a "done" value so any operator using a timer will need to handle the "done" case.

Instructor: [0:00] Moving on to the next demo, I'm just going to check out to before the React refactor and I realized making this demo, once I type in STAR, you'll see in the Network tab, we're back to making two requests, which means that I made the classic blunder of using, when I created my waitFor, using a create timeout without handling the done.

[0:26] I'm going to call this value timeoutValue. If timeoutValue is done, just guard against it. When I search again, type in STAR, we're back to a single request. Again, this is the scenario to watch out for once you're using things that can't be done inside of other operators. We never want waitFor to be done because of this. We make it a done from outside of it, but it has no concept of an internal done.