You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,14 +38,17 @@ Extensions for interoperability with Arrow's `Either` type:
38
38
-**Conversion** - `toAsyncResult()` to convert `Either` to `AsyncResult`
39
39
-**Binding** - `bind()` to flatten `AsyncResult<Either<L, R>>` to `AsyncResult<R>`
40
40
-**Flow conversion** - `asAsyncResult()` to convert `Flow<Either<L, R>>` to `Flow<AsyncResult<R>>`, `toEither()` to convert `Flow<AsyncResult<T>>` to `Either`
41
+
-**Arrow Raise** - `Raise<Error>.bind()` to use `AsyncResult` inside Arrow's `either { }` / `result { }` blocks
41
42
42
43
### asyncresult-test
43
44
44
45
Testing utilities built on [assertk](https://github.com/willowtreeapps/assertk):
By default, it attempts to extract the error type from the `Error.metadata`.
131
+
132
+
## Arrow Raise integration
133
+
134
+
Use `AsyncResult` inside Arrow's `Raise` context (e.g., `either { }` or `result { }` blocks):
135
+
136
+
```kotlin
137
+
importio.nlopez.asyncresult.either.bind
138
+
139
+
val either:Either<Error, User> = either {
140
+
val user = fetchUser().bind() // extracts Success or raises Error
141
+
user
142
+
}
143
+
```
144
+
145
+
The `Raise<Error>.bind()` extension extracts the value from `Success`, or raises (`shift`) the `Error` for non-success states (`Loading` and `NotStarted` raise `Error.Empty`).
@@ -53,6 +54,7 @@ Extensions for interoperability with Arrow's `Either` type:
53
54
-**Conversion** - `toAsyncResult()` to convert `Either` to `AsyncResult`
54
55
-**Binding** - `bind()` to flatten `AsyncResult<Either<L, R>>` to `AsyncResult<R>`
55
56
-**Flow conversion** - `asAsyncResult()` to convert `Flow<Either<L, R>>` to `Flow<AsyncResult<R>>`, `toEither()` to convert `Flow<AsyncResult<T>>` to `Either`
57
+
-**Arrow Raise** - `Raise<Error>.bind()` to use `AsyncResult` inside Arrow's `either { }` / `result { }` blocks
56
58
57
59
[View full documentation](either.md)
58
60
@@ -62,7 +64,9 @@ Testing utilities built on [assertk](https://github.com/willowtreeapps/assertk):
0 commit comments