What's Changed
- Feature: Improve API helpers and error handling callbacks by @seangwright in #18
- Feature: Result.tapEither/Async by @seangwright in #19
- feat(api): add bindFailure & bindFailureAsync by @GregOnNet in #22
fetchResponse
fetchResponse
now returns the Response
instead of Unit
, giving the consumer more context to inform their next steps. This is a breaking change.
The error handlers for fetchResponse
and fetchJsonResponse
can now return Promise
s. This can be helpful if, for example, an API request returns a 400 response with a JSON body that needs to be unwrapped with response.json()
.
tapEither
Result.tapEither
, Result.tapEitherAsync
, and ResultAsync.tapEither
can all be used to perform a side effect action independent of the result succeeding or failing. This can be useful if, for example, the state of a component (ex: isLoading
) should be toggled when the result of an operation completes - either in a success or failure scenario.
bindFailure
Result.bindFailure
, Result.bindFailureAsync
, and ResultAsync.bindFailure
can be used to convert a failed result to another result. This covers the combination of bind
and mapFailure
.
Full Changelog: v1.4.0...v2.0.0