Component Structure


This document describes the structure and documentation of a component.

Types

The following types should be implemented:

  • Model - the components model
  • Msg - the messages the component can receive
    • NoOp (if applicable) - No operation message

Functions

The following functions should be implemented similarly:

  • init : ValueType -> (additional arguments...) -> Model
  • subscribe : (ValueType -> msg) -> Model -> Sub msg
  • subscriptions : Sub Msg
  • update : Msg -> Model -> (Model, Cmd Msg)
  • view : (additional arguments...) -> Model -> Html.Html Msg
  • render: (additional arguments...) -> Model -> Html.Html Msg
  • setValue : 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
  • Bool field that is a flag - "Whether or not the component name is field description"

results matching ""

    No results matching ""