Exercise - AsyncSubject
Exercise
The goal of the exercise is to capture the position of the mouse event when the capture button is clicked.
- Open exercise on codesandbox.
- I've already imported the
AsyncSubjectclass for you. - Create a new
AsyncSubjectinstance and specify the generic typeMouseEventfor the next notification value. - Subscribe to the
AsyncSubjectinstance and set thexandyinput values to the event'spageXandpageYvalues accordingly. Since we're using TypeScript you'll need to properly set the value property to astring. - Subscribe to the
clicksObservable using theasyncSubjectas the Observer. - Finally, complete the
AsyncSubjectinstance when the user has clicked on the button. You'll need to use thefromEvent()operator or add an event listener to theHTMLButtonElement.