ResultPipingAsync<T> extension
Methods
-
ok<T2>(T2 f(T))
→ Future<Result<T2>>
-
If
result
is Err
then returns this Err
as is.
If result
is Ok
then returns result of call f(result.val)
.
Result of call f() must be a value of type T2.
-
okAsync<T2>(Future<T2> f(T))
→ Future<Result<T2>>
-
If
result
is Err
then returns this Err
as is.
If result
is Ok
then returns result of call await f(result.val)
.
Result of call f() must be a value of type T2.
-
onErr(dynamic f(Error))
→ Future<Result<T>>
-
Calls f(result.err) with side effect if this result is Err.
Anyway returns this result as is.
-
onOk(dynamic f(T))
→ Future<Result<T>>
-
Calls f(result.val) with side effect if this result is Ok.
Anyway returns this result as is.
-
onResult(dynamic f(Result<T>))
→ Future<Result<T>>
-
Calls f(this) with side effect and return this as is.
-
or(T? f())
→ Future<Result<T>>
-
If this result is Ok, then returns it as is.
If this result is Err, then call
result = f()
.
If result of call f() is null, then returns Err.
If result of call f() is value , then return Ok(value).
If call of f() throws exception, then returns Err.
-
orAsync(Future<T?> f())
→ Future<Result<T>>
-
If this result is Ok, then returns it as is.
If this result is Err, then call
result = await f()
.
If result of call f() is null, then returns Err.
If result of call f() is value, then return Ok(value).
If call of f() throws exception, then returns Err.
-
pipe<T2>(dynamic f(T))
→ Future<Result<T2>>
-
If
result
is Err
then returns this Err
as is.
If result
is Ok
then returns result of call f(result.val).
If result of call f() is null - returns Err('function returned null').
If result of call f() is Result
- returns it as is.
If call of f() throws exception, then returns Err
.
-
pipeAsync<T2>(Future f(T))
→ Future<Result<T2>>
-
If
result
is Err
then returns this Err
as is.
If result
is Ok
then returns result of call await f(result.val)
.
If result of call f() is null - returns Err('function returned null').
If result of call f() is Result
- returns it as is.
If call of f() throws exception, then returns Err
.