opvasger/amr/3.1.1

Rerouted (cache, verified). The original is gone. This copy comes from a Lamdera package cache made before it went. The Lamdera package server serves a copy recovered from a Lamdera package cache from 2021-02-13.

What we checked: Rebuilt from the unpacked sources in a Lamdera package cache (5 copies agree), which Elm only writes after the published SHA-1 checked out; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, so its SHA-1 is not the published one.

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/opvasger/amr/zipball/3.1.1/

AMR

This module helps you set up an Elm program with automatic message-replay.

Configuration

type alias Config flags msg =
{ encodeMsg : msg -> Value
, msgDecoder : Decoder msg
, fromCache : flags -> Maybe String
, toCache : String -> Cmd msg
}

This is the configuration required for automatic message-replay.

Let's say your program is initialized in HTML like this:

<script>
    const app = Elm.Main.init({
        node: document.body,
        flags: {
            amr : localStorage.getItem("app-amr")
        }
    })


    app.ports.toCache.subscribe(output =>
        localStorage.setItem("app-amr", output)
    )
</script>

The configuration for that script would be like this:

port toCache : Maybe String -> Cmd msg


fromCache =
    .amr

encodeMsg and msgDecoder depends how messages are defined. You can find an example here.

Programs

This API mirrors elm/browser.

Config flags msg
-> { init : model
, view : model -> Html msg
, update : msg -> model -> model
}
-> Program flags model msg

Create a “sandboxed” program that cannot communicate with the outside world. More about that here.

Config flags msg
-> { init : flags -> ( model, Cmd msg )
, view : model -> Html msg
, update : msg -> model -> ( model, Cmd msg )
, subscriptions : model -> Sub msg
}
-> Program flags model msg

Create an HTML element managed by Elm. More about that here.

Config flags msg
-> { init : flags -> ( model, Cmd msg )
, subscriptions : model -> Sub msg
, update : msg -> model -> ( model, Cmd msg )
, view : model -> Document msg
}
-> Program flags model msg

Create an HTML document managed by Elm. More about that here.

Config flags msg
-> { init : flags -> Url -> Key -> ( model, Cmd msg )
, update : msg -> model -> ( model, Cmd msg )
, subscriptions : model -> Sub msg
, view : model -> Document msg
, onUrlChange : Url -> msg
, onUrlRequest : UrlRequest -> msg
}
-> Program flags model msg

Create an application that manages Url changes. More about that here.

type alias Program flags model msg =
Program flags (Model model) msg

A program with automatic message-replay enabled.