State<S, A> class
final
State<S, A>
is used to store, update, and extract 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 State
(Account Balance fetched from the current state of your Bank Account S
).
- Inheritance
- Mixed-in types
-
- Functor2<
_StateHKT, S, A> - Applicative2<
_StateHKT, S, A> - Monad2<
_StateHKT, S, A>
- Functor2<
Constructors
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 State< S, C> then()) → State<S, C> -
Chain the result of
then
to this State.override -
ap<
C> (covariant State< S, C Function(A a)> a) → State<S, C> -
Apply the function contained inside
a
to change the value of typeA
to a value of typeC
.override -
call<
C> (covariant State< S, C> state) → State<S, C> -
Chain multiple functions having the same state
S
.override -
chainFirst<
C> (covariant State< S, C> chain(A a)) → State<S, A> -
Chain a request that returns another State, execute it, ignore
the result, and return the same value as the current State.
override
-
evaluate(
S state) → A -
Execute
run
and extract the valueA
. -
execute(
S state) → S -
Execute
run
and extract the stateS
. -
flatMap<
C> (covariant State< S, C> f(A a)) → State<S, C> -
Used to chain multiple functions that return a State.
override
-
get(
) → State< S, S> -
Extract the current state
S
. -
gets(
A f(S state)) → State< S, A> -
Change the value getter based on the current state
S
. -
map<
C> (C f(A a)) → State< S, C> -
Change the value inside
State<S, A>
from typeA
to typeC
usingf
.override -
map2<
C, D> (covariant State< S, C> m1, D f(A a, C c)) → State<S, D> -
Change type of this State based on its value of type
A
and the value of typeC
of another State.override -
map3<
C, D, E> (covariant State< S, C> m1, covariant State<S, D> m2, E f(A a, C c, D d)) → State<S, E> -
Change type of this State based on its value of type
A
, the value of typeC
of a second State, and the value of typeD
of a third State.override -
modify(
S f(S state)) → State< S, Unit> -
Change the current state
S
usingf
and return nothing (Unit). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pure<
C> (C c) → State< S, C> -
Return a
State<S, C>
containingc
as value.override -
put(
S state) → State< S, Unit> - Set a new state and return nothing (Unit).
-
run(
S state) → (A, S) -
Extract value
A
and stateS
by passing the original stateS
. -
toStateAsync(
) → StateAsync< S, A> - Lift a sync State to an async StateAsync.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
sequenceList<
S, A> (List< State< list) → State<S, A> >S, List< A> > -
Convert a
List<State<S, A>>
to a singleState<S, List<A>>
. -
traverseList<
S, A, B> (List< A> list, State<S, B> f(A a)) → State<S, List< B> > -
Map each element in the list to a State using the function
f
, and collect the result in aState<S, List<B>>
. -
traverseListWithIndex<
S, A, B> (List< A> list, State<S, B> f(A a, int i)) → State<S, List< B> > -
Map each element in the list to a State using the function
f
, and collect the result in aState<S, List<B>>
.