How can I obtain an Observable of an Event in Angular 2?
For instance, is it possible to subscribe to a click event but only trigger after two clicks? Can we create an Observable of MouseClick
event objects?
If I want to filter by button
or ctrlKey
, or have an Observable of KeyboardEvent
and filter by key
\ keyCode
, or any potential future scenarios?
I came across which mentioned the property valueChanges
as Observable<string>
.
In addition, on https://github.com/angular/angular/issues/5489, there was a method demonstrated as follows:
this.clickStream = new Subject();
...
<button (click)="clickStream.next($event)">Click Me</button>
Is using the Subject
method shown above the correct approach? I am uncertain.
While I lack experience with Angular 2 and RxJS, I am interested in both and exploring them for potential use in upcoming projects.
Edit
Here's my Plunker showcasing a simple click use case http://plnkr.co/edit/u1A7ve2fAYigjwaZ0x1v?p=preview