Open OliverJAsh opened 3 years ago
Sounds good. We could name them analog to the Array
methods head
and tail
.
Here's another one: fromFetch
. If the user loses connectivity by the time you subscribe to the observable, fetch
will reject and thereby the observable will emit an error.
Here's a wrapper we've been using at Unsplash around RxJS' fromFetch
.
ObservableEither<FetchError | ResponseJsonParseError, Either.Json>
https://stackblitz.com/edit/fp-ts-rxjs-fromfetch?file=index.ts
🚀 Feature request
Current Behavior
In RxJS, some operators are known to throw exceptions intentionally, in non-exceptional circumstances.
For example, the
first
operator will throw anEmptyError
if the observable completes after having emitted no items (an empty observable). https://rxjs-dev.firebaseapp.com/api/operators/firstOther operators which throw:
last
,single
, and the forthcominglastValueFrom
/firstValueFrom
(RxJS 7).Desired Behavior
Operators which don't throw.
Suggested Solution
For example, this library could provide its own
first
operator which would returnObservable<Option<T>>
. If the observable is empty, the observable would emitnone
instead of throwing an exception / emitting an error.