Skip to content

v2.0.0 - Expand fetch helpers, new Result methods

Latest
Compare
Choose a tag to compare
@seangwright seangwright released this 07 May 01:52

What's Changed

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 Promises. 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