Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(Observer): add documentation to Observer interface #6948

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,41 @@ export interface CompletionObserver<T> {

export type PartialObserver<T> = NextObserver<T> | ErrorObserver<T> | CompletionObserver<T>;

/**
* An object interface that defines a set of callback functions a user can use to get
* notified of any set of {@link Observable}
* {@link guide/glossary-and-semantics#notification notification} events.
*
* For more info, please refer to {@link guide/observer this guide}.
*/
export interface Observer<T> {
/**
* A callback function that gets called by the producer during the subscription when
* the producer "has" the `value`. It won't be called if `error` or `complete` callback
* functions have been called, nor after the consumer has unsubscribed.
*
* For more info, please refer to {@link guide/glossary-and-semantics#next this guide}.
*/
next: (value: T) => void;
/**
* A callback function that gets called by the producer if and when it encountered a
* problem of any kind. The errored value will be provided through the `err` parameter.
* This callback can't be called more than one time, it can't be called if the
* `complete` callback function have been called previously, nor it can't be called if
* the consumer has unsubscribed.
*
* For more info, please refer to {@link guide/glossary-and-semantics#error this guide}.
*/
error: (err: any) => void;
/**
* A callback function that gets called by the producer if and when it has no more
* values to provide (by calling `next` callback function). This means that no error
* has happened. This callback can't be called more than one time, it can't be called
* if the `error` callback function have been called previously, nor it can't be called
* if the consumer has unsubscribed.
*
* For more info, please refer to {@link guide/glossary-and-semantics#complete this guide}.
*/
complete: () => void;
}

Expand Down