Timer and Input Recap

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

This lesson recaps everything we’ve covered about building a timer stream, and input stream, and how we’ve combined all their parts together.

J. Matthew
~ 5 years ago

I just want to point out that, technically, the game doesn't end after three seconds, but rather three emissions from the interval Observable. The duration between those emissions depends on which "starter" button you click—and, in fact, you can change that midstream by clicking a different button.

So you could make the game really hard by clicking Quarter and only having three-fourths of a second to score any points. Or you could click Start to begin with a one-second interval and score a point, but then click Half mid-game to give yourself only a half-second window from then on.

J. Matthew
~ 5 years ago

Actually, now that I think about it more, it's not even three emissions—the game ends whenever the value of that count property within any emission exceeds 3. Since we increment the count by 1 on each emission of the interval Observable, and we typically hit the Start button, which sets a one-second duration between emissions, it more or less amounts to ending the game after three seconds. But, in addition to the customizable interval as described in the previous comment, we could also modify how much count increments each emission. And don't forget about that Reset button—you can use that to keep the game going indefinitely.