unsubscribe is not a function on an observable

Discussão em 'Angular' iniciado por Nate May, Abril 28, 2025.

  1. Nate May

    Nate May Guest

    Here is my Observable

    this.mouseMove$ = Observable.fromEvent(document, 'mousemove')


    With this implementation, I have no problem subscribing in this way:

    this.mouseMove$.subscribe();


    However, I cannot seem to unsubscribe in either of the following ways:

    this.mouseMove$.unsubscribe();
    this.mouseMove$.dispose();


    In both cases, I get the following type of error:


    TypeError: this.mouseMove$.unsubscribe is not a function ...
    ​

    I'm unsure if this has to do with the mouseMove$ type of any, but setting the type as Observable and Observable<MouseEvent> did not work. What am I not understanding here?

    Continue reading...

Compartilhe esta Página