TaskOption<R> class

TaskOption<R> represents an asynchronous computation that may fails yielding a None or returns a Some(R) when successful.

If you want to represent an asynchronous computation that never fails, see Task.

If you want to represent an asynchronous computation that returns an object when it fails, see TaskEither.

Inheritance
Mixed in types

Constructors

TaskOption(Future<Option<R>> _run())
Build a TaskOption from a function returning a Future<Option<R>>.
const
TaskOption.Do(DoFunctionTaskOption<R> f)
Initialize a Do Notation chain.
factory
TaskOption.flatten(TaskOption<TaskOption<R>> taskOption)
Flat a TaskOption contained inside another TaskOption to be a single TaskOption.
factory
TaskOption.fromNullable(R? r)
If r is null, then return None. Otherwise return Right(r).
factory
TaskOption.fromPredicate(R value, bool predicate(R a))
When calling predicate with value returns true, then running TaskOption returns Some(value). Otherwise return None.
factory
TaskOption.fromTask(Task<R> task)
Build a TaskOption from the result of running task.
factory
TaskOption.none()
Build a TaskOption that returns a None.
factory
TaskOption.of(R r)
Build a TaskOption that returns a Some(r).
factory
TaskOption.some(R r)
Build a TaskOption that returns a Some(r).
factory
TaskOption.tryCatch(Future<R> run())
Converts a Future that may throw to a Future that never throws but returns a Option instead.
factory

Properties

hashCode int
The hash code for this object.
read-onlyinherited
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

alt(covariant TaskOption<R> orElse()) TaskOption<R>
When this TaskOption returns Some, then return the current TaskOption. Otherwise return the result of orElse.
override
andThen<C>(covariant TaskOption<C> then()) TaskOption<C>
If running this TaskOption returns Some, then return the result of calling then. Otherwise return None.
override
ap<C>(covariant TaskOption<C Function(R r)> a) TaskOption<C>
Apply the function contained inside a to change the value on the Some from type R to a value of type C.
override
call<B>(covariant TaskOption<B> chain) TaskOption<B>
Chain multiple TaskOption functions.
override
chainFirst<B>(covariant Monad<_TaskOptionHKT, B> chain(R a)) HKT<_TaskOptionHKT, R>
inherited
delay(Duration duration) TaskOption<R>
Creates a TaskOption that will complete after a time delay specified by a Duration.
flatMap<C>(covariant TaskOption<C> f(R r)) TaskOption<C>
Used to chain multiple functions that return a TaskOption.
override
getOrElse(R orElse()) Task<R>
Convert this TaskOption to a Task.
map<C>(C f(R r)) TaskOption<C>
If running this TaskOption returns Some, then change its value from type R to type C using function f.
override
map2<C, D>(covariant TaskOption<C> m1, D f(R b, C c)) TaskOption<D>
Change the return type of this TaskOption based on its value of type R and the value of type C of another TaskOption.
override
map3<C, D, E>(covariant TaskOption<C> m1, covariant TaskOption<D> m2, E f(R b, C c, D d)) TaskOption<E>
Change the return type of this TaskOption based on its value of type R, the value of type C of a second TaskOption, and the value of type D of a third TaskOption.
override
match<A>(A onNone(), A onSome(R r)) Task<A>
Pattern matching to convert a TaskOption to a Task.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orElse<TL>(TaskOption<R> orElse()) TaskOption<R>
When this TaskOption returns a None then return the result of orElse. Otherwise return this TaskOption.
pure<C>(C c) TaskOption<C>
Returns a TaskOption that returns Some(c).
override
run() Future<Option<R>>
Run the task and return a Future<Option<R>>.
toString() String
A string representation of this object.
inherited
toTaskEither<L>(L onNone()) TaskEither<L, R>
Convert this TaskOption to TaskEither.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromEither<L, R>(Either<L, R> either) TaskOption<R>
Build a TaskOption from either that returns None when either is Left, otherwise it returns Some.
sequenceList<A>(List<TaskOption<A>> list) TaskOption<List<A>>
Convert a List<TaskOption<A>> to a single TaskOption<List<A>>.
sequenceListSeq<A>(List<TaskOption<A>> list) TaskOption<List<A>>
Convert a List<TaskOption<A>> to a single TaskOption<List<A>>.
traverseList<A, B>(List<A> list, TaskOption<B> f(A a)) TaskOption<List<B>>
Map each element in the list to a TaskOption using the function f, and collect the result in an TaskOption<List<B>>.
traverseListSeq<A, B>(List<A> list, TaskOption<B> f(A a)) TaskOption<List<B>>
Map each element in the list to a TaskOption using the function f, and collect the result in an TaskOption<List<B>>.
traverseListWithIndex<A, B>(List<A> list, TaskOption<B> f(A a, int i)) TaskOption<List<B>>
Map each element in the list to a TaskOption using the function f, and collect the result in an TaskOption<List<B>>.
traverseListWithIndexSeq<A, B>(List<A> list, TaskOption<B> f(A a, int i)) TaskOption<List<B>>
Map each element in the list to a TaskOption using the function f, and collect the result in an TaskOption<List<B>>.
tryCatchK<R, A>(Future<R> run(A a)) TaskOption<R> Function(A a)
Converts a Future that may throw to a Future that never throws but returns a Option instead.