# Elm Msg Replay

This package implements reliable hot-reloading based on the Elm-architecture.

It is sheer delight to build graphics without having to get the application back
into a certain state in between making changes.

## Automatic Message-Replay

![Demo Gif](https://raw.githubusercontent.com/opvasger/msg-replay/0293828e73ef1b764a700bd8b003da202402871e/demo.gif)

The only case where replay can be limited, is when a message is removed from
code, and the application is restarted. In this case, replay happens up until
that message and stops. This is optimal.

If we ignore limited replay, it essentially works like this:

```elm
init flags =
    ( List.foldl (\msg model -> Tuple.first (update msg model))
        initModel 
        (decodeListOfMsg flags.msgs)
    , Cmd.none
    )

update msg model =
    case msg of
        DoStuff ->
            ( doStuff model
            , saveMsgOverPort (encode msg)
            )
```

One really interesting aspect of automatic message-replay, is how a program
behaves when the update-function is modified.

If you run through the correct set of actions to reach a certain state, but
you're not quite there, you can tweak the update-function of your program, and
simply reload the program to see if you're done yet.
