Building a Stopwatch
Explore how to build a functional stopwatch using RxJS observables. This lesson guides you through creating observables that monitor user clicks on start and stop buttons, as well as an interval observable that tracks time. Understand how to connect these observables to the DOM and manage internal state effectively, preparing you to apply these techniques in more complex reactive applications.
We'll cover the following...
Stopwatch project
Enough theory, you’re probably itching to start building something. The first project you’ll take on in this course is a stopwatch that contains three observables. The stopwatch will have two buttons, one for starting and one for stopping, with an observable monitoring each.
Behind the scenes will be a third observable, ticking away the seconds since the start button was pressed in increments of 1/10th of a second.
This observable will be hooked up to a counter on the page. You’ll learn how to create observables that take input from the user and observables that interact with the DOM to display the latest state of your app.
Working application
Below is the working application of our stopwatch built using observables. You will build these observables in the upcoming lessons.
Feel free to play with it.