prevent need for passing in Html.map to each route

This commit is contained in:
Ryan Haskell-Glatz 2019-10-11 22:16:24 -05:00
parent d94a449191
commit 4350dab437
2 changed files with 17 additions and 16 deletions

View File

@ -35,6 +35,11 @@ type Msg
| NotFoundMsg Never
app =
{ bundle = Application.bundle Html.map
}
pages =
{ homepage =
Page.static
@ -176,36 +181,31 @@ bundle :
bundle appModel =
case appModel of
HomepageModel model ->
Application.bundle
app.bundle
{ page = pages.homepage
, model = model
, toHtml = Html.map
}
CounterModel model ->
Application.bundle
app.bundle
{ page = pages.counter
, model = model
, toHtml = Html.map
}
RandomModel model ->
Application.bundle
app.bundle
{ page = pages.random
, model = model
, toHtml = Html.map
}
SignInModel model ->
Application.bundle
app.bundle
{ page = pages.signIn
, model = model
, toHtml = Html.map
}
NotFoundModel model ->
Application.bundle
app.bundle
{ page = pages.notFound
, model = model
, toHtml = Html.map
}

View File

@ -432,19 +432,20 @@ type alias TitleViewSubs appMsg =
bundle :
{ page : Page route flags contextModel contextMsg model msg appModel appMsg pageElement
, model : model
, toHtml : (msg -> appMsg) -> pageElement -> Html appMsg
}
((msg -> appMsg) -> pageElement -> Html appMsg)
->
{ page : Page route flags contextModel contextMsg model msg appModel appMsg pageElement
, model : model
}
-> Bundle flags route contextModel appMsg
bundle config context =
bundle toHtml config context =
{ title =
Page.title
config.page
context
config.model
, view =
config.toHtml (Page.toMsg config.page) <|
toHtml (Page.toMsg config.page) <|
Page.view
config.page
context