Handling User Input
Let's see how to track the clicks in RxJS using the built-in "fromEvent" operator in Rx.
We'll cover the following
Managing clicks
The next step is to manage clicks on the start and stop buttons. First, grab the elements off the page with querySelector
:
let startButton = document.querySelector('#start-button');
let stopButton = document.querySelector('#stop-button');
Tracking click events
Now that we have buttons, we need to figure out when the user clicks them. You could use the constructor covered in the last section to build an observable that streams click events from an arbitrary element:
Get hands-on with 1400+ tech skills courses.