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.

Inheritance
Mixed in types

Constructors

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

Properties

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

Methods

andThen<C>(covariant StateAsync<S, C> then()) StateAsync<S, C>
Chain the result of then to this StateAsync.
override
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.
override
call<C>(covariant StateAsync<S, C> state) StateAsync<S, C>
Chain multiple functions having the same state S.
override
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.
override
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.
override
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.
override
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.
override
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.
override
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.
inherited
pure<C>(C c) StateAsync<S, C>
Return a StateAsync<S, C> containing c as value.
override
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.
inherited

Operators

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