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
AsyncSubject
class for you. - Create a new
AsyncSubject
instance and specify the generic typeMouseEvent
for the next notification value. - Subscribe to the
AsyncSubject
instance and set thex
andy
input values to the event'spageX
andpageY
values accordingly. Since we're using TypeScript you'll need to properly set the value property to astring
. - Subscribe to the
clicks
Observable using theasyncSubject
as the Observer. - Finally, complete the
AsyncSubject
instance when the user has clicked on the button. You'll need to use thefromEvent()
operator or add an event listener to theHTMLButtonElement
.