hooks library

Classes

Composite<T>
A Composite of multiple parent States.

Functions

compose<T>(Action<T> composition) Composite<T>
A hook to efficiently create a read-only Composited State from the composition of one or multiple parent states. For more simpler use cases, calling the composition as is should be sufficient.
managed<T, E extends Enum>(T value, {required Manager<T, E> manager}) ManagedState<T, E>
A hook that allows any given State to be programmatically managed such that it does not get arbitrarily updated with values that do not follow a given contract as specified by a Manager function. This may be used to aid in maing sure the State of the value falls within a finite number of States.

Typedefs

Dispatcher<E extends Enum> = void Function(E event)
A function that takes in an event (in the form of an Enum) on how the State should be updated.
ManagedState<T, E extends Enum> = (ReadOnlyState<T>, Dispatcher<E>)
A tuple that contains the State itself and a Dispatcher function.
Manager<T, E extends Enum> = void Function(WritableState<T> state, {required E event})
The user defined function that manages the State it is paired with. The Manager constraints how State should be updated, protecting it from arbitrary updates that are not desirable to have.