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

Constructors

State((A, S) _run(S state))
Build a new State given a (A, S) Function(S).
const
State.flatten(State<S, State<S, A>> state)
Flat a State contained inside another State to be a single State.
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 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 type A to a value of type C.
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 value A.
execute(S state) → S
Execute run and extract the state S.
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 type A to type C using f.
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 type C 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 type C of a second State, and the value of type D of a third State.
override
modify(S f(S state)) State<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) State<S, C>
Return a State<S, C> containing c 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 state S by passing the original state S.
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