Component Structure
This document describes the structure and documentation of a component.
Types
The following types should be implemented:
Model- the components modelMsg- the messages the component can receiveNoOp(if applicable) - No operation message
Functions
The following functions should be implemented similarly:
init : ValueType -> (additional arguments...) -> Modelsubscribe : (ValueType -> msg) -> Model -> Sub msgsubscriptions : Sub Msgupdate : Msg -> Model -> (Model, Cmd Msg)view : (additional arguments...) -> Model -> Html.Html Msgrender: (additional arguments...) -> Model -> Html.Html MsgsetValue : ValueType -> Model -> Model(if applicable)
Ordering & Documentation
Module
- Description of the component
- Model - model related types and functions
- View - view related functions
- Functions - other component functions
- Any other custom sections
Types
- Types should come in this order
Model- "Representation of a(n) component name:" followed by description of it's fields in a list.Msg- "Messages that a(n) component name can receive."- All other types and their documentation.
Functions
Functions should come in this order (each followed by an example with fully qualified module name)
init- "Initializes a(n) component name."update- "Updates a(n) component name."subscribe- "Subscribe to the changes of a(n) component name."subscriptions- "Subscriptions for a(n) component name"view- "Lazily renders a(n) component name."render- "Renders a(n) component name."setValue- "Sets the value of the given componen name"- all other functions
Fields
- They should follow the same order as in the definition
- Field name should be bold
Boolfield that is a flag - "Whether or not the component name is field description"