From ce22672a3db7c035e1089744b6479635edf00a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pacana?= Date: Fri, 26 Jan 2024 18:43:58 +0100 Subject: [PATCH] Inline Extracted function save a few lines but did not help with clarity. --- ruby_event_store-browser/elm/src/Main.elm | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Main.elm b/ruby_event_store-browser/elm/src/Main.elm index 2486db2925..0abdfdbb34 100644 --- a/ruby_event_store-browser/elm/src/Main.elm +++ b/ruby_event_store-browser/elm/src/Main.elm @@ -89,12 +89,22 @@ update msg model = ) ( GotShowStreamMsg showStreamUIMsg, ShowStream showStreamModel ) -> - Page.ShowStream.update showStreamUIMsg showStreamModel - |> updateWith ShowStream GotShowStreamMsg model + let + ( subModel, subCmd ) = + Page.ShowStream.update showStreamUIMsg showStreamModel + in + ( { model | page = ShowStream subModel } + , Cmd.map GotShowStreamMsg subCmd + ) ( GotShowEventMsg openedEventUIMsg, ShowEvent showEventModel ) -> - Page.ShowEvent.update openedEventUIMsg showEventModel - |> updateWith ShowEvent GotShowEventMsg model + let + ( subModel, subCmd ) = + Page.ShowEvent.update openedEventUIMsg showEventModel + in + ( { model | page = ShowEvent subModel } + , Cmd.map GotShowEventMsg subCmd + ) ( GotLayoutMsg layoutMsg, _ ) -> case model.flags of @@ -112,13 +122,6 @@ update msg model = ( model, Cmd.none ) -updateWith : (subModel -> Page) -> (subMsg -> Msg) -> Model -> ( subModel, Cmd subMsg ) -> ( Model, Cmd Msg ) -updateWith toPageModel toMsg model ( subModel, subCmd ) = - ( { model | page = toPageModel subModel } - , Cmd.map toMsg subCmd - ) - - urlUpdate : Model -> Url.Url -> ( Model, Cmd Msg ) urlUpdate model location = case model.flags of