-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
affects: @userlike/messenger-types
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* This is the interface for observables as defined in | ||
* https://github.com/tc39/proposal-observable. It's a proposal, but lots of | ||
* libraries implement this interface. Most prominent one is rxjs, which is also | ||
* used by Angular. | ||
*/ | ||
export interface Observable<T> { | ||
// Subscribes to the sequence with an observer | ||
subscribe(observer: Observer<T>): Subscription; | ||
|
||
// Subscribes to the sequence with callbacks | ||
subscribe( | ||
onNext: (v: T) => void, | ||
onError?: (err: unknown) => void, | ||
onComplete?: () => void | ||
): Subscription; | ||
} | ||
|
||
export interface Subscription { | ||
// Cancels the subscription | ||
unsubscribe(): void; | ||
|
||
// A boolean value indicating whether the subscription is closed | ||
closed: boolean; | ||
} | ||
|
||
export interface Observer<T> { | ||
// Receives the next value in the sequence | ||
next(value: T): void; | ||
|
||
// Receives the sequence error | ||
error(errorValue: unknown): void; | ||
|
||
// Receives a completion notification | ||
complete(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters