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
#### Chain others [Result] by `Error` value with `flatMapError`
167
-
168
-
```dart
169
-
170
-
void main() {
171
-
final result = getNumberResult()
172
-
.flatMapError((e) => checkError(e));
173
-
}
174
-
```
175
-
176
-
#### Add a pure `Success` value with `pure`
177
-
178
-
```dart
179
-
void main() {
180
-
final result = getSomethingPretty().pure(10);
181
-
182
-
String? mySuccessResult;
183
-
if (result.isSuccess()) {
184
-
mySuccessResult = result.tryGetSuccess(); // 10
185
-
}
186
-
}
187
-
```
188
-
189
-
#### Add a pure `Error` value with `pureError`
190
-
191
-
```dart
192
-
void main() {
193
-
final result = getSomethingPretty().pureError(10);
194
-
if (result.isError()) {
195
-
result.tryGetError(); // 10
196
-
}
197
-
}
198
-
```
199
-
#### Swap a `Result` with `swap`
200
-
201
-
```dart
202
-
void main() {
203
-
Result<String, int> result =...;
204
-
Result<int, String> newResult = result.swap();
205
-
}
206
-
```
207
-
208
125
## Unit Type
209
126
210
127
Some results do not need a specific return. Use the Unit type to signal an empty return.
211
128
212
129
```dart
213
130
Result<Unit, Exception>
214
131
```
132
+
## ResultOf
215
133
216
-
## Use **AsyncResult** type:
217
-
218
-
`AsyncResult<S, E>` represents an asynchronous computation.
219
-
Use this component when working with asynchronous **Result**.
220
-
221
-
**AsyncResult** has some of the operators of the **Result** object to perform data transformations (**Success** or **Error**) before executing the Future.
222
-
223
-
The operators of the **Result** object available in **AsyncResult** are:
224
-
225
-
- map
226
-
- mapError
227
-
- flatMap
228
-
- flatMapError
229
-
- pure
230
-
- pureError
231
-
- swap
232
-
233
-
`AsyncResult<S, E>` is a **typedef** of `Future<Result<S, E>>`.
0 commit comments