StateAsync<S, A> class final

StateAsync<S, A> is used to store, update, and extract async state in a functional way.

S is a State (e.g. the current State of your Bank Account). A is value that you extract out of the StateAsync (Account Balance fetched from the current state of your Bank Account S).

Used when fetching and updating the state is asynchronous. Use State otherwise.

Mixed in types


StateAsync(Future<(A, S)> _run(S state))
Build a new StateAsync given a Future<(A, S)> Function(S).
StateAsync.flatten(StateAsync<S, StateAsync<S, A>> state)
Flat a StateAsync contained inside another StateAsync to be a single StateAsync.
StateAsync.fromState(State<S, A> state)
Build a new StateAsync by lifting a sync State to async.


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


andThen<C>(covariant StateAsync<S, C> then()) StateAsync<S, C>
Chain the result of then to this StateAsync.
ap<C>(covariant StateAsync<S, C Function(A a)> a) StateAsync<S, C>
Apply the function contained inside a to change the value of type A to a value of type C.
call<C>(covariant StateAsync<S, C> state) StateAsync<S, C>
Chain multiple functions having the same state S.
chainFirst<C>(covariant StateAsync<S, C> chain(A a)) StateAsync<S, A>
Chain a request that returns another StateAsync, execute it, ignore the result, and return the same value as the current StateAsync.
evaluate(S state) Future<A>
Execute run and extract the value A.
execute(S state) Future<S>
Execute run and extract the state S.
flatMap<C>(covariant StateAsync<S, C> f(A a)) StateAsync<S, C>
Used to chain multiple functions that return a StateAsync.
get() StateAsync<S, S>
Extract the current state S.
gets(A f(S state)) StateAsync<S, A>
Change the value getter based on the current state S.
map<C>(C f(A a)) StateAsync<S, C>
Change the value inside StateAsync<S, A> from type A to type C using f.
map2<C, D>(covariant StateAsync<S, C> m1, D f(A a, C c)) StateAsync<S, D>
Change type of this StateAsync based on its value of type A and the value of type C of another StateAsync.
map3<C, D, E>(covariant StateAsync<S, C> m1, covariant StateAsync<S, D> m2, E f(A a, C c, D d)) StateAsync<S, E>
Change type of this StateAsync based on its value of type A, the value of type C of a second StateAsync, and the value of type D of a third StateAsync.
modify(S f(S state)) StateAsync<S, Unit>
Change the current state S using f and return nothing (Unit).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
pure<C>(C c) StateAsync<S, C>
Return a StateAsync<S, C> containing c as value.
put(S state) StateAsync<S, Unit>
Set a new state and return nothing (Unit).
run(S state) Future<(A, S)>
Extract value A and state S by passing the original state S.
toString() String
A string representation of this object.


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