Composing State
Introduction
We advocate for creating atomic state and to compose new state when you need to.
There are several composition operations that you can perform and that we will see below.
One key aspect of composing state is that it returns another ConanState, which you can compose again.
One state to one state
Map
We can derive one state into a new one using ConanState.map:
Filter
We can filter 1 state into a new one using ConanState.filter:
Two states to one state
Merge
We can merge 2 states into 1 using ConanState.merge:
Tuple
Many states to one state
Combine
We can combine N states into a new one using ConanState.combine: