Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 724 Bytes

File metadata and controls

33 lines (24 loc) · 724 Bytes

コンテキスト

典型的な update view関数は次のようになります:

view : Model -> Html Msg
view model =
  ...

あるいは

update : Msg -> Model -> (Model, Cmd Msg)
update message model =
  ...

このコンポーネントのModelだけを渡すということで非常にシンプルな話です。しかし、余分な情報が必要なとき、viewに追加的な情報を渡すのも問題ありません。例えば:

type alias Context =
  { model : Model
  , time : Time
  }

view : Context -> Html Msg
view context =
  ...

この関数は、親モデルで定義されているコンポーネントモデルとtimeを必要としています。