elm-spa/docs.json

1 line
15 KiB
JSON
Raw Normal View History

2019-11-01 07:51:56 +03:00
[{"name":"Application","comment":" Let's build some single page applications!\n\n\n# Terrifying types ahead 😬\n\nThe `elm-spa` package makes your _functions look nice_,\nbut holy cow do those type annotations get intimidating!\n\n\n## But why tho? 🤔\n\nSo much of the types are defined in _your app_, and this package needs\nto use generic types to understand them correctly.\n\nIn practice, this actually leads to your code looking like this\n\n init route_ =\n case route_ of\n Route.Foo route ->\n foo.init route\n\n Route.Bar route ->\n bar.init route\n\n Route.Baz route ->\n baz.init route\n\n _ ->\n Page.keep model_\n\n( Instead of a crazy nested torture chamber of doom )\n\n\n## Anyway, enough excuses from me! 🤐\n\nCheck out the examples below to decide for yourself!\n\n\n# Program\n\nAt a high-level, `elm-spa` replaces [Browser.application](https://package.elm-lang.org/packages/elm/browser/latest/Browser#application)\nso you don't have to deal with `Url` or `Nav.Key`!\n\nYou can create a `Program` with `Application.create`:\n\n module Main exposing (main)\n\n import Application\n import Generated.Pages as Pages\n import Generated.Route as Route\n import Global\n\n main =\n Application.create\n { options = Application.defaultOptions\n , routing =\n { routes = Route.routes\n , toPath = Route.toPath\n , notFound = Route.NotFound ()\n }\n , global =\n { init = Global.init\n , update = Global.update\n , subscriptions = Global.subscriptions\n }\n , page = Pages.page\n }\n\n\n\n@docs Program, create\n\n\n# Using elm-ui?\n\nIf you're a fan of [mdgriffith/elm-ui](https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/),\nit's important to support using `Element msg` instead of `Html msg` for your pages and components.\n\nLet `Application.create` know about this by passing in your own `Options` like these:\n\n import Element\n -- other imports\n\n Application.create\n { options =\n { toHtml = Element.layout []\n , map = Element.map\n }\n , -- ... the rest of your app\n }\n\n@docs Options, defaultOptions\n\n","unions":[],"aliases":[{"name":"Options","comment":" Useful for using packages like [elm-ui](https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/)\n\n import Element\n\n options =\n { toHtml = Element.layout []\n , map = Element.map\n }\n\nThis tells your app how to convert into `Html msg` when it's time to render to the page.\n\n","args":["layoutMsg","globalMsg","htmlLayoutMsg","htmlMsg"],"type":"{ toHtml : htmlMsg -> Html.Html (Application.Msg globalMsg layoutMsg), map : (layoutMsg -> Application.Msg globalMsg layoutMsg) -> htmlLayoutMsg -> htmlMsg }"},{"name":"Program","comment":" An alias for `Platform.Program` to make annotations a little more clear.\n","args":["flags","globalModel","globalMsg","layoutModel","layoutMsg"],"type":"Platform.Program flags (Application.Model flags globalModel layoutModel) (Application.Msg globalMsg layoutMsg)"}],"values":[{"name":"create","comment":" Creates a new `Program` given some one-time configuration:\n\n - `options` - How do we convert the view to `Html msg`?\n - `routing` - What are the app's routes?\n - `global` - How do we maintain the global app state\n - `page` - What pages do we have available?\n\n","type":"{ options : Application.Options layoutMsg globalMsg htmlLayoutMsg htmlMsg, routing : { routes : Application.Routes route, toPath : route -> String.String, notFound : route }, global : { init : { navigate : route -> Platform.Cmd.Cmd (Application.Msg globalMsg layoutMsg) } -> flags -> ( globalModel, Platform.Cmd.Cmd globalMsg, Platform.Cmd.Cmd (Application.Msg globalMsg layoutMsg) ), update : { navigate : route -> Platform.Cmd.Cmd (Application.Msg