ryannhg/elm-spa/5.1.0

NOTE: the latest version is 6.0.0

Renamed to ryan-haskell/elm-spa. It is published under that name, and new versions come out there.

Versions published as ryannhg/elm-spa still install under that name. 13 versions of 13 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/ryan-haskell/elm-spa.

What we checked: The repo moved to github.com/ryan-haskell/elm-spa. Rebuilt with git archive from commit 0f8cc5975728 of https://github.com/ryan-haskell/elm-spa (zip prefix ryannhg-elm-spa-a6cff43/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 a78b13a810a6d2699c69edddb9e5621190a3e006.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/ryannhg/elm-spa/zipball/5.1.0/

ElmSpa.Request

( These docs are for CLI contributors )

If you are using elm-spa, check out the official guide instead!


Every page gets access to a request, which has information about the current URL, route parameters, query parameters etc.

page : Shared.Model -> Request Params -> Page Model Msg
page _ request =
    Page.element
        { init = init
        , update = update
        , view = view request
        }

You can choose to pass this request into init,update, or any other function that might need access to URL-related information.

Requests

type alias Request route params =
{ url : Url
, key : Key
, route : route
, params : params
, query : Dict String String
}

Here is an example request for the route /people/:name

-- /people/ryan
req.route == Route.People__Detail_ { name = "ryan" }


req.params == { name = "ryan" }


req.params.name == "ryan"


req.query == Dict.empty

And another example with a some query parameters:

-- /people/scott?allowed=false
req.route == Route.People__Detail_ { name = "scott" }


req.params == { name = "scott" }


req.params.name == "scott"


Dict.get "allowed" req.query == Just "false"
create : route -> params -> Url -> Key -> Request route params

A convenience function for creating requests, used by elm-spa internally.

request : Request Route { name : String }
request =
    Request.create (Route.fromUrl url)
        { name = "ryan" }
        url
        key