I would appreciate some help with a problem involving subscriptions. I'm trying to prevent a callback function from being invoked by a delayed subscription in case a specific event happens, but I can't help managing to do it!
I've tried calling .unsubscribe()
, when the event handler is triggered, but that didn't stop the callback from being executed.
Here's the definition of my subscription:
this.sub = Observable
.of(true)
.pipe(
delay(2000)
)
.subscribe(() => {
foo()
});
And here's what I've tried:
this.elRef.nativeElement.onmouseover = () => {
if (this.sub) {
this.sub.unsubscribe();
}
};
Thanks in advance