From a813c72f5bf5933b35732dd15b2771c14982b519 Mon Sep 17 00:00:00 2001 From: vlinder Date: Thu, 21 Jan 2021 13:15:23 +0100 Subject: [PATCH 1/2] Make subscribe callbacks optional in the typings According do the documentation All callbacks on the Observer interface are optional. --- type-definitions/most.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/type-definitions/most.d.ts b/type-definitions/most.d.ts index a8db93a8..e7260b81 100644 --- a/type-definitions/most.d.ts +++ b/type-definitions/most.d.ts @@ -49,10 +49,10 @@ export interface Observable { } export interface Subscriber { - next(value: A): void; - error(err: Error): void; + next?(value: A): void; + error?(err: Error): void; // complete value parameter is deprecated - complete(value?: A): void; + complete?(value?: A): void; } export interface Subscription { From f7a54e4308fcf6b04033c1fea7ddd3931be29cc6 Mon Sep 17 00:00:00 2001 From: vlinder Date: Thu, 21 Jan 2021 13:20:48 +0100 Subject: [PATCH 2/2] Update docs to reflect actual behaviour. --- docs/api.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index 24f61d53..f92518fb 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1160,18 +1160,18 @@ The returned promise will fulfill after all the events have been consumed, or wi #### `stream.subscribe(Observer) -> Subscription` -Draft ES Observable compatible subscribe. Start consuming events from `stream` by providing an [Observer object](https://github.com/zenparsing/es-observable#observer). +Draft ES Observable compatible subscribe. Start consuming events from `stream` by providing an [Observer object](https://github.com/zenparsing/es-observable#observer). All methods on `Observer` are optional. ```js type Observer = { // Receives the next value in the sequence - next(value) => void + next?(value) => void // Receives the sequence error - error(errorValue) => void + error?(errorValue) => void // Receives the sequence completion signal // The completionValue parameter is deprecated - complete(completionValue) => void + complete?(completionValue) => void } ```