MattCheely / tryframe-coordinator / Message.ClientToHost

This module exposes a type representing all of the messages that can be passed from the client library to the host library via postMessage.


type ClientToHost
    = NavRequest Message.Navigation.Navigation
    | Publish Message.PubSub.Publication
    | ToastRequest Message.Toast.Toast

This custom type is just a set of variants for each valid message the client library can send to the host library across the iframe boundary. See the individual type descriptions for more details on message structures.

encodeToHost : ClientToHost -> Json.Encode.Value

Encodes a ClientToHost message for delivery to the host library via postMessage.

decodeFromClient : Json.Decode.Decoder ClientToHost

Decoder for parsing incoming messages from the client library to the host library. Bad input from postMessage will produce nice console errors that describe the exact failure.