Reputation: 117
What role does pipe(take(1)) have when calling the method from authService?
this.authService
.signIn(email, password)
.pipe(take(1))
.subscribe(...)
Upvotes: 4
Views: 5570
Reputation: 15443
From the rxjs-docs:
Take returns an Observable that emits only the first count values emitted by the source Observable. If the source emits fewer than count values then all of its values are emitted. After that, it completes, regardless if the source completes.
Upvotes: 1
Reputation: 13515
take(1)
will unsubscribe after 1 value has been received. This is useful for tidying up subscriptions to long running observables when you know you only want the first result.
Upvotes: 6