opvasger/amr/3.0.1

NOTE: the latest version is 3.1.1

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/opvasger/amr is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 3.0.1 found (32 same-name repos checked); no cached copy. Use another version.

Details

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 : 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.