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 3d6830fdaea3 of https://github.com/ryan-haskell/elm-spa (zip prefix ryannhg-elm-spa-6c89d93/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 ef713492aac6715e88fba5231c42f7d1caec7175.
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/6.0.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.SignInPrefixing any of the four functions above with protected will guarantee that the page has access to a user. Here's an example with sandbox:
-- before
Page.sandbox
{ init = init
, update = update
, view = view
}
-- after
Page.protected.sandbox
(\user ->
{ init = init
, update = update
, view = view
}
)
-- other functions have same API
init : Model
update : Msg -> Model -> Model
view : 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!
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!