Angular 2 - Does subscribing to FormControl's valueChanges need an unsubscribe?

Discussão em 'Angular' iniciado por user1902183, Novembro 7, 2024.

  1. user1902183

    user1902183 Guest

    Below is a simple example of what I am asking about:

    class AppComponent {

    someInput: FormControl = new FormControl('');
    private subscription: Subscription;

    constructor(){

    this.subscription = this.someInput.valueChanges
    .subscribe(() => console.log("testing"));
    }
    }


    I have 2 questions:

    1) Do I have to eventually unsubscribe from this? 2) Most importantly, whatever the answer is to #1, WHY is that the answer?

    Any insight would be appreciated!

    Thanks!

    Continue reading...

Compartilhe esta Página