Suppose I have nested Elmish components like this: A
contains B
contains C
.
Then if C
has state and messages, these must be passed from C
to B
and then to A
.
For example, the message and model types for B
might be:
type Message =
| CMessage of C.Message
| UpdateFoo of string
type Model =
{
Foo : string
C : C.Model
}
Then update
for B
will do some routing:
let update message model =
match message with
| CMessage m ->
{
model with
C = C.update m model.C
}
| UpdateFoo foo -> { model with Foo = foo }
Then the same must be done for A
consuming B
messages.
This is quite verbose compared to setState
, for example.
What are some strategies for managing this in Elmish?