Skip to content

Commit 7e078a6

Browse files
committed
Add await info on promise rejections and flatMap(fromPromise)
1 parent a1b497a commit 7e078a6

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

docs/api.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,19 @@ stream.await(): ---1--2--3->
910910

911911
Note that event order is preserved, regardless of promise fulfillment order. The fulfilled event values will arrive at the later of the original event time and the promise fulfillment time.
912912

913+
If a promise rejects, the stream will be in an error state with the rejected promise's reason as its error. See [flatMapError](#flatmaperror) for error recovery. For example:
914+
915+
```
916+
promise p: ---1
917+
promise q: ------X
918+
promise r: -3
919+
stream: -p---q---r->
920+
stream.await(): ---1--X
921+
```
922+
923+
Functionally, `stream.await()` and `stream.flatMap(most.fromPromise)` are equivalent, but `await` is much more efficient.
924+
925+
913926
```js
914927
var urls = [url1, url2, url3, ...];
915928

0 commit comments

Comments
 (0)