Starting with RxJS and want to create a simple stream of button clicks, so I simply do this:
export class AppComponent {
button : HTMLElement = document.querySelector('button');
refreshClickStream$ = Observable.fromEvent(this.button, 'click')
.subscribe();
constructor(){
}
but receive that error in console...
Also tried it like this:
clicked(e) {
return Observable.fromEvent(e.target, 'click')
.do(console.log)
.subscribe();
}
But after first click I get no output in console. After second click I get one MouseEvent object. After third click I get two MouseEvent Objects. After fourth click I get three of them etc. So I think click event handler duplicates with RxJS fromEvent
function.
Any explanations are very welcome..