gcanti / fp-ts-rxjs

fp-ts bindings for RxJS
https://gcanti.github.io/fp-ts-rxjs/
MIT License
187 stars 29 forks source link

trycatch #48

Closed anthonyjoeseph closed 3 years ago

anthonyjoeseph commented 3 years ago

Closes #31

Related: gcanti/fp-ts#1376

Version of https://github.com/gcanti/fp-ts-rxjs/pull/46, branched from 0.6.12

gcanti commented 3 years ago

@anthonyjoeseph what about a simpler signature?

/**
 * @category constructors
 * @since 0.6.12
 */
export const tryCatch: <A>(a: Observable<A>) => ObservableEither<unknown, A> =
  /*#__PURE__*/
  flow(R.map(E.right), catchError(flow(E.left, R.of)))
anthonyjoeseph commented 3 years ago

I love that signature! Updated

gcanti commented 3 years ago

@anthonyjoeseph thanks. This branch has conflicts, maybe you have an old docs-ts version locally.

anthonyjoeseph commented 3 years ago

Ah thanks for the tip! I wasn't sure why that kept happening. Updated

OliverJAsh commented 3 years ago

It looks like this version of tryCatch doesn't accept a function to handle/convert the error, unlike all other implementations of tryCatch such as TaskEither.tryCatch. Are we planning to make all other implementations match this one, or should we make this one consistent with the rest?

gcanti commented 3 years ago

Are we planning to make all other implementations match this one

yes