task_option
library
Classes
-
TaskOption<A>
-
Represents a Task that resolves to an Option.
Useful for creating async operations that might return nothing.
Functions
-
alt<A>(TaskOption<A> onNone())
→ TaskOption<A> Function(TaskOption<A> taskOption)
-
If the TaskOption resolves to None, then the alternative TaskOption
will be used.
-
chainNullable<A>(TaskOption<A?> taskOption)
→ TaskOption<A>
-
A chainable fromNullable variant that flattens nullable values into an
Option.
-
chainNullableK<A, B>(B? f(A a))
→ TaskOption<B> Function(TaskOption<A> value)
-
A chainable fromNullable variant that transforms the given TaskOption
into a nullable value, then flattens the result.
-
chainTryCatchK<A, B>(FutureOr<B> task(A value))
→ TaskOption<B> Function(TaskOption<A> taskOption)
-
A chainable variant of tryCatchK, that unwraps the given TaskOption.
-
delay<A>(Duration duration)
→ TaskOption<A> Function(TaskOption<A> taskOption)
-
-
Do<A>(DoFunction<A> f)
→ TaskOption<A>
-
-
filter<A>(bool predicate(A value))
→ TaskOption<A> Function(TaskOption<A> taskOption)
-
Conditionally transform the TaskOption to a None, using the given
predicate.
-
flatMap<A, B>(TaskOption<B> f(A value))
→ TaskOption<B> Function(TaskOption<A> taskOption)
-
Transform the given TaskOption into a new TaskOption, if it resolves to
a Some value.
-
flatMapFirst<A>(TaskOption f(A value))
→ TaskOption<A> Function(TaskOption<A> taskOption)
-
Similar to flatMap, except Some values are discarded.
-
flatMapTask<A, B>(Task<B> f(A value))
→ TaskOption<B> Function(TaskOption<A> taskOption)
-
-
flatMapTuple2<A, A2>(TaskOption<A2> f(A a))
→ TaskOption Function(TaskOption<A> o)
-
A variant of flatMap that appends the result to a tuple.
-
flatMapTuple3<A, A2, A3>(TaskOption<A3> f(dynamic a))
→ TaskOption<Tuple3<A, A2, A3>> Function(TaskOption o)
-
A variant of flatMap that appends the result to a tuple.
-
fold<A, B>(B onNone(), B onSome(A value))
→ Task<B> Function(TaskOption<A> taskOption)
-
Transforms the TaskOption into a Task, using the given
onNone
and onSome
callbacks.
-
fromEither<L, R>(Either<L, R> either)
→ TaskOption<R>
-
Returns a TaskOption that resolves to an Option from the given Either.
Left values become None, Right values are wrapped in Some.
-
fromNullable<A>(A? a)
→ TaskOption<A>
-
Create a TaskOption from a value that could be
null
. If it is not null
,
then it will resolve to Some. null
values become None.
-
fromNullableK<A, B>(B? f(A a))
→ TaskOption<B> Function(A value)
-
A fromNullable variant that allows for external values to be passed in.
-
fromNullableWith<A>()
→ TaskOption<A> Function(A? value)
-
A fromNullable variant that enforces the input type.
Useful for function composition.
-
fromOption<A>(Option<A> option)
→ TaskOption<A>
-
Returns a TaskOption that resolves to the given Option.
-
fromPredicate<A>(A value, bool predicate(A value))
→ TaskOption<A>
-
Returns a Some or None if the predicate returns
true
or false
respectively.
-
fromPredicateK<A>(bool predicate(A value))
→ TaskOption<A> Function(A a)
-
Returns a Some or None if the predicate returns
true
or false
respectively.
-
fromTask<A>(Task<A> task)
→ TaskOption<A>
-
Wraps the value from a Task in a Some.
-
getOrElse<A>(A orElse())
→ Task<A> Function(TaskOption<A> taskOption)
-
Transforms the TaskOption into a Task, by unwrapping the Some value or
using the
orElse
value if it resolves to None.
-
map<A, B>(B f(A value))
→ TaskOption<B> Function(TaskOption<A> taskOption)
-
Transforms a TaskOption value if it resolves to Some.
-
none<A>()
→ TaskOption<A>
-
Returns a TaskOption that resolves to None.
-
orElse<A>(TaskOption<A> task)
→ TaskOption<A> Function(TaskOption<A> taskOption)
-
A variant of alt, which accepts the replacement TaskOption directly.
-
pure<A, B>(B b)
→ TaskOption<B> Function(TaskOption<A> taskOption)
-
Replaces the TaskOption with one that resolves to a Some wrapping the
given value.
-
sequence<A>(Iterable<TaskOption<A>> tasks)
→ TaskOption<IList<A>>
-
-
sequenceSeq<A>(Iterable<TaskOption<A>> tasks)
→ TaskOption<IList<A>>
-
-
some<A>(A a)
→ TaskOption<A>
-
Returns a TaskOption that resolves to Some.
-
tap<A>(FutureOr<void> f(A value))
→ TaskOption<A> Function(TaskOption<A> taskOption)
-
Perform a side effect if the TaskOption is a Some.
-
tryCatch<A>(Lazy<FutureOr<A>> task)
→ TaskOption<A>
-
Runs the given task, and wraps the result with Some.
If it throws and error, it will return None.
-
tryCatchK<A, B>(FutureOr<B> task(A value))
→ TaskOption<B> Function(A value)
-
A variant of tryCatch, that allows external values to be passed in.