MattCheely / tryframe-coordinator / Message.PubSub

The other messages in this library cover common use cases for coordination between host and client applications, but there is often some coordination required specific to the application domain. To that end, the Message.PubSub module provides a set of types for publishing to topics as well as subscribing and unsubscribing from them.

Publishing


type alias Publication =
{ topic : String
, payload : Json.Decode.Value 
}

This is the type used by host and client applications to publish any data to a topic.

encodePublication : Publication -> Json.Decode.Value

Encodes a Publication to JSON, tagging it with publishLabel

publicationDecoder : Json.Decode.Decoder Publication

Decoder for publication messages, which are expected to be tagged with publishLabel

publishLabel : String

This is the label used to tag publish events in JSON. Other modules should not need to reference it, but it is exposed to force a package version bump if it changes.

Subscription Management

subscribeDecoder : Json.Decode.Decoder String

Decoder for subscription requests, which are just a topic string tagged with subscribeLabel.

subscribeLabel : String

This is the label used to tag subscribe requests in JSON. Other modules should not need to reference it, but it is exposed to force a package version bump if it changes.

unsubscribeDecoder : Json.Decode.Decoder String

Decoder for unsubscribe requests, which are just a topic string tagged with unsubscribeLabel.

unsubscribeLabel : String

This is the label used to tag unsubscribe requests in JSON. Other modules should not need to reference it, but it is exposed to force a package version bump if it changes.