-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
, onClickPlus = ProgressMsg Progress.CounterPlus | ||
, onClickMinus = ProgressMsg Progress.CounterMinus | ||
, onClickPlus = \ps -> { ps | value = Progress.clampValue (ps.value + 13) } | ||
, onClickMinus = \ps -> { ps | value = Progress.clampValue (ps.value - 11) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ view : Html (props -> props) }
にすると、外のmsgを使えないのがお悩みポイントではある。
制約と思えば今のところは許せるので、妥協案に変更しました。
@@ -160,6 +160,7 @@ progressPlayground : Bool -> Progress.Model -> Html Msg | |||
progressPlayground isDarkMode pm = | |||
playground | |||
{ isDarkMode = isDarkMode | |||
, toMsg = UpdateProgress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
寄せてはみたものの、このPRではまだview関数のままなので、toMsg : (a -> a) -> msg
をここで指定して辻褄合わせしています。フィールド毎に指定する必要がなくなったので、全体的な記述はすっきりしたかなと。
@@ -92,6 +92,11 @@ update msg model = | |||
( model, Random.generate SetValue (Random.int -15 -10) ) | |||
|
|||
|
|||
clampValue : Float -> Float | |||
clampValue = | |||
max 0 >> min 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilotがこれで良いんじゃない?って言ってたのを採用。
(min 100 (max 0 n)
が微妙に分かりづらい印象を受けたので、ポイントフリースタイルにしてみた)
type alias Control props = | ||
{ view : Html (props -> props) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新APIに寄せつつも、段階的に進めるべく、このPRではview関数の形を維持しています。
#34 の実装を受けて、既存の
Control
モジュール側からも新APIに寄せてみます