mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 23:12:22 +03:00
Use action for todos example.
This commit is contained in:
parent
344ef2919a
commit
f33e5bac25
@ -55,7 +55,7 @@ route =
|
||||
RouteBuilder.serverRender
|
||||
{ head = head
|
||||
, data = data
|
||||
, action = \_ -> Request.skip "No action."
|
||||
, action = action
|
||||
}
|
||||
|> RouteBuilder.buildWithLocalState
|
||||
{ view = view
|
||||
@ -179,6 +179,19 @@ todoSelection =
|
||||
|
||||
data : RouteParams -> Parser (DataSource (Response Data ErrorPage))
|
||||
data routeParams =
|
||||
Request.oneOf
|
||||
[ Request.requestTime
|
||||
|> Request.map
|
||||
(\time ->
|
||||
Request.Fauna.dataSource (time |> Time.posixToMillis |> String.fromInt) todos
|
||||
|> DataSource.map Data
|
||||
|> DataSource.map Response.render
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
action : RouteParams -> Parser (DataSource (Response ActionData ErrorPage))
|
||||
action _ =
|
||||
Request.oneOf
|
||||
[ Form.submitHandlers (deleteItemForm "")
|
||||
(\model decoded ->
|
||||
@ -189,7 +202,7 @@ data routeParams =
|
||||
(\_ -> Route.redirectTo Route.Todos)
|
||||
|
||||
Err error ->
|
||||
{ todos = [] }
|
||||
{}
|
||||
|> Response.render
|
||||
|> DataSource.succeed
|
||||
)
|
||||
@ -202,18 +215,10 @@ data routeParams =
|
||||
(\_ -> Route.redirectTo Route.Todos)
|
||||
|
||||
Err error ->
|
||||
{ todos = []
|
||||
}
|
||||
{}
|
||||
|> Response.render
|
||||
|> DataSource.succeed
|
||||
)
|
||||
, Request.requestTime
|
||||
|> Request.map
|
||||
(\time ->
|
||||
Request.Fauna.dataSource (time |> Time.posixToMillis |> String.fromInt) todos
|
||||
|> DataSource.map Data
|
||||
|> DataSource.map Response.render
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user