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
-
- Functor2<
_StateAsyncHKT, S, A> - Applicative2<
_StateAsyncHKT, S, A> - Monad2<
_StateAsyncHKT, S, A>
- Functor2<
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< state)S, A> > -
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
thento this StateAsync.override -
ap<
C> (covariant StateAsync< S, C Function(A a)> a) → StateAsync<S, C> -
Apply the function contained inside
ato change the value of typeAto a value of typeC.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
runand extract the valueA. -
execute(
S state) → Future< S> -
Execute
runand extract the stateS. -
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 typeAto typeCusingf.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
Aand the value of typeCof 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 typeCof a second StateAsync, and the value of typeDof a third StateAsync.override -
modify(
S f(S state)) → StateAsync< S, Unit> -
Change the current state
Susingfand 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>containingcas value.override -
put(
S state) → StateAsync< S, Unit> - Set a new state and return nothing (Unit).
-
run(
S state) → Future< (A, S)> -
Extract value
Aand stateSby passing the original stateS. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override