Reputation: 573
In rxjs what exactly does the observer.complete() do after observer.next() ?
Upvotes: 12
Views: 8619
Reputation: 6825
In ReactiveX library, there are two types of messages.
First ones are ordinary messages. Ordinary messages are the ones sent with .next()
and there can be 0-many of them.
Second type are notifications. These can be of two types - error and success. The error is sent with .error()
and give some error details in it (like exception) and success is sent with .complete()
meaning that there will intentionally be no messages. Every observable should end with a single error or a single success notification.
Upvotes: 6
Reputation: 48367
From the documentation observer.complete
notifies the Observer
that the Observable has finished sending push-based notifications.
In the other hand, observer.complete
it's a callback function and an Observable calls this method after it has called next() for the final time, if it has not encountered any errors.
Upvotes: 10