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 29dbd364b09f of https://github.com/ryan-haskell/elm-spa (zip prefix ryannhg-elm-spa-10457c5/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 f0efb3044ca4fa8ccff3d24c10556f402c2fa051.
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.2.0/
A page that only needs to render a static view.
import Page
page : Page () Never
page =
Page.static
{ view = view
}
-- view : View NeverA page that can keep track of application state.
( Inspired by Browser.sandbox )
import Page
page : Page Model Msg
page =
Page.sandbox
{ init = init
, update = update
, view = view
}
-- init : Model
-- update : Msg -> Model -> Model
-- view : Model -> View MsgA page that can handle effects like HTTP requests or subscriptions.
( Inspired by Browser.element )
import Page
page : Page Model Msg
page =
Page.element
{ init = init
, update = update
, view = view
, subscriptions = subscriptions
}
-- init : ( Model, Cmd Msg )
-- update : Msg -> Model -> ( Model, Cmd Msg )
-- view : Model -> View Msg
-- subscriptions : Model -> Sub MsgA page that can handles custom effects like sending a Shared.Msg or other general user-defined effects.
import Effect
import Page
page : Page Model Msg
page =
Page.advanced
{ init = init
, update = update
, view = view
, subscriptions = subscriptions
}
-- init : ( Model, Effect Msg )
-- update : Msg -> Model -> ( Model, Effect Msg )
-- view : Model -> View Msg
-- subscriptions : Model -> Sub MsgActions to take when a user visits a protected page
import Gen.Route as Route exposing (Route)
beforeProtectedInit : Shared.Model -> Request () -> Protected User Route
beforeProtectedInit shared _ =
case shared.user of
Just user ->
Provide user
Nothing ->
RedirectTo Route.SignInThis will become protected, and protected will be removed in the v6 release. Keeping them both to prevent a version bump!
Prefixing any of the four functions above with protected will guarantee that the page has access to a user. Here's an example with sandbox:
import Page
page : Page Model Msg
page =
Page.protected.sandbox
{ init = init
, update = update
, view = view
}
-- init : User -> Model
-- update : User -> Msg -> Model -> Model
-- update : User -> Model -> View MsgA convenient function for use within generated code. Makes it easy to handle init, update, view, and subscriptions for each page!
This function is used by the generated code to connect your pages together.
It's big, spooky, and makes writing elm-spa pages really nice!
This will be removed before release, included to prevent bumping to 6.0.0 during beta!
Deprecated! Will be replaced by protected2
Pages are the building blocks of elm-spa.
Instead of importing this module, your project will have a
Pagemodule with a much simpler type:This makes all the generic
route,effect, andviewarguments disappear!