mirror of
https://github.com/ryannhg/elm-spa.git
synced 2024-11-22 09:44:55 +03:00
prevent need for passing in Html.map to each route
This commit is contained in:
parent
d94a449191
commit
4350dab437
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user