Website dev guide fixes for Code Structure page

This commit is contained in:
Keavon Chambers 2024-02-19 00:12:30 -08:00
parent 229b5dbb20
commit f265fa693e
1 changed files with 5 additions and 5 deletions

View File

@ -35,24 +35,24 @@ Messages are enum variants that are dispatched to perform some intended activity
```rs ```rs
pub enum DocumentMessage { pub enum DocumentMessage {
... ...
// A message that carries a layer path and a string as data // A message that carries one named data field
DocumentMessage::DeleteLayer { DeleteLayer {
id: NodeId, id: NodeId,
} }
// A message that carries no data // A message that carries no data
DocumentMessage::DeleteSelectedLayers, DeleteSelectedLayers,
... ...
} }
``` ```
As shown above, data can be included with each message. But as a special case denoted by the `#[child]` attribute, that data can also be a sub-message, which enables us to nest message handler systems hierarchically. The `DocumentMessage` enum of the previous example is defined as a child of `PortfolioMessage` which wraps it like this: As shown above, additional data fields can be included with each message. But as a special case denoted by the `#[child]` attribute, that data can also be a sub-message, which enables us to nest message handler systems hierarchically. By convention, regular data must be written as struct-style named fields (shown above), while a sub-message must be written as an unnamed tuple/newtype-style field (shown below). The `DocumentMessage` enum of the previous example is defined as a child of `PortfolioMessage` which wraps it like this:
```rs ```rs
pub enum PortfolioMessage { pub enum PortfolioMessage {
... ...
// A message that carries the `DocumentMessage` child enum as data // A message that carries the `DocumentMessage` child enum as data
#[child] #[child]
PortfolioMessage::Document(DocumentMessage), Document(DocumentMessage),
... ...
} }
``` ```