single page apps made easy
Go to file
Ryan Haskell-Glatz dff6118d97
Update README.md
2019-11-02 14:44:28 -05:00
cli release cli as elm-spa 2019-11-02 13:50:50 -05:00
examples i feel much better about the elm docs now 🙂 2019-11-01 00:30:18 -05:00
src ready for publish 2019-11-01 22:54:22 -05:00
.gitignore cli generates things for you 2019-10-31 00:05:55 -05:00
.npmignore exclude elm stuff 2019-11-01 22:57:00 -05:00
docs.json i feel much better about the elm docs now 🙂 2019-11-01 00:30:18 -05:00
elm-analyse.json a fresh start :) 2019-10-15 23:52:54 -05:00
elm.json write up some docs for the package 2019-10-31 22:06:59 -05:00
LICENSE add license because laws 2019-11-01 00:32:49 -05:00
netlify.toml a fresh start :) 2019-10-15 23:52:54 -05:00
package.json release cli as elm-spa 2019-11-02 13:50:50 -05:00
README.md Update README.md 2019-11-02 14:44:28 -05:00

ryannhg/elm-spa

an experiment for creating single page apps with Elm!

Note: the API is still experimental! (join the conversation on discourse)

trying it out

npm install -g elm-spa
elm-spa init your-project

just using the elm package?

elm install ryannhg/elm-spa

overview

module Main exposing (main)

import Application
import Generated.Pages as Pages
import Generated.Route as Route
import Global


main =
    Application.create
        { ui = Application.usingHtml
        , routing =
            { routes = Route.routes
            , toPath = Route.toPath
            , notFound = Route.NotFound ()
            }
        , global =
            { init = Global.init
            , update = Global.update
            , subscriptions = Global.subscriptions
            }
        , page = Pages.page
        }

keep your pages simple

(Instead of making everything an elm-fork-knife!)

page =
    Page.static
        { title = title
        , view = view
        }
page =
    Page.sandbox
        { title = title
        , init = init
        , update = update
        , view = view
        }
page =
    Page.element
        { title = title
        , init = init
        , update = update
        , subscriptions = subscriptions
        , view = view
        }
page =
    Page.component
        { title = title
        , init = init
        , update = update
        , subscriptions = subscriptions
        , view = view
        }

while the top level stays easy to read!

init appRoute =
    case appRoute of
        Route.Index route ->
            index.init route

        Route.Counter route ->
            counter.init route

        Route.Random route ->
            random.init route

( It's like magic, but actually it's just functions. )

run the example

this project comes with an example in examples/html.

Here's how to run it:

  1. git clone https://github.com/ryannhg/elm-spa.git && cd elm-spa

  2. npm install

  3. npm run dev