Does async pipe automatically unsubscribe from observable, if I change the observable?

csiki100

I'm trying to make a language pipe with ngrx.

component.html:

<p>{{1 | language: languageId | async }}</p>

language pipe:

constructor(private store:Store){}

  transform(resourceId: number, languageId:number): Observable<string> {
    return this.store.select(selectResource, { resourceId, languageId });
  }

My question is, if I change the languageId in my component, then the pipe will select a new Observable from the store, but will the async pipe unsubscribe from the previous Observable, or do I have to do it manually?

ibenjelloun

Yes the async will handle the unsubscribe if the Observable instance has changed.

Here is a running example on stackblitz.

Pipe returning new observable every input change subscribed with async

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Is unsubscribe needed if an Observable uses an async pipe?

I tried to do unsubscribe from an observable in angular But I am getting error like unsubscribe does not exists

Do I need to unsubscribe from an Angular Observable?

Should I unsubscribe from Cold Observable?

Do I have to unsubscribe from completed observable?

Do I have to unsubscribe from completed observable?

How can I subscribe and unsubscribe from an observable?

RxJava: Unsubscribe async observable from within another async production

Do I need to unsubscribe from an Observable if the Observable is finished with?

Template does not render observable using async pipe

is there a pipe operator that will unsubscribe from an inner observable of inner observables?

Async Pipe not showing data from observable

unsubscribe does not exist on type Observable<>?

does multiple async pipe on a same observable in template cause more change detections?

Unsubscribe all listeners from Observable

Angular unsubscribe from BehaviorSubject as Observable

function method to unsubscribe from observable

Should I unsubscribe from an Observable derived from a Subject?

What happens when I unsubscribe from an Observable chain?

How do I unsubscribe from inner observables in redux observable?

Reusing Async Pipe (Observable) Output

How to async pipe an observable in Angular

Async pipe and subscribe on the same Observable

Observable Async Pipe Not Returning Values

The Async pipe doesn't receive a value until I subscribe to the observable

Read object field from observable using async pipe

Unit testing value of Observable returned from service (using async pipe)

Using an array from Observable Object with ngFor and Async Pipe Angular 2

Property 'unsubscribe' does not exist on type 'Observable<DataSnapshot>'