compose<T> function
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.
Implementation
Composite<T> compose<T>(Action<T> composition) {
final WritableState<T> internalState = state();
final publicState = ReadOnlyState(internalState);
final computation = compute(() => internalState.set(composition()));
return Composite(publicState, computation);
}