diff --git a/src/Application.elm b/src/Application.elm index 6c79b9f..b6cba6a 100644 --- a/src/Application.elm +++ b/src/Application.elm @@ -354,16 +354,16 @@ element = Page.element -type alias Glue route layoutModel layoutMsg = - Page.Glue route layoutModel layoutMsg +type alias Glue params layoutModel layoutMsg = + Page.Glue params layoutModel layoutMsg -type alias Pages route layoutModel layoutMsg = - Page.Pages route layoutModel layoutMsg +type alias Pages params layoutModel layoutMsg = + Page.Pages params layoutModel layoutMsg glue : - Glue route layoutModel layoutMsg + Glue params layoutModel layoutMsg -> Page params layoutModel layoutMsg model msg glue = Page.glue diff --git a/src/Internals/Page.elm b/src/Internals/Page.elm index 6bbffd3..7bd30b4 100644 --- a/src/Internals/Page.elm +++ b/src/Internals/Page.elm @@ -133,24 +133,36 @@ element page { toModel, toMsg } = -- LAYOUT -type alias Glue route model msg = - { layout : Layout msg - , pages : Pages route model msg +type alias Glue params layoutModel layoutMsg = + { layout : Layout layoutMsg + , pages : Pages params layoutModel layoutMsg } -type alias Pages route model msg = - { init : route -> ( model, Cmd msg ) - , update : msg -> model -> ( model, Cmd msg ) - , bundle : model -> Bundle msg +type alias Pages params layoutModel layoutMsg = + { init : params -> ( layoutModel, Cmd layoutMsg ) + , update : layoutMsg -> layoutModel -> ( layoutModel, Cmd layoutMsg ) + , bundle : layoutModel -> Bundle layoutMsg } glue : - Glue route layoutModel layoutMsg + Glue params layoutModel layoutMsg -> Page params layoutModel layoutMsg model msg glue options { toModel, toMsg } = - { init = Debug.todo "glue.init" - , update = Debug.todo "glue.update" - , bundle = Debug.todo "glue.bundle" + { init = + options.pages.init >> Tuple.mapBoth toModel (Cmd.map toMsg) + , update = + \msg model -> + options.pages.update msg model + |> Tuple.mapBoth toModel (Cmd.map toMsg) + , bundle = + \model -> + let + page = + options.pages.bundle model + in + { view = options.layout.view { page = page.view } |> Html.map toMsg + , subscriptions = Sub.none + } }