niho/elm-stomp/1.0.0

Stomp.Proc

A remote procedure call (the request/response pattern).

import Stomp.Proc
import Stomp.Client


type Msg = Click | Response (Result String (List String))


update : Msg -> State -> (State, Cmd Msg)
update msg state =
    case msg of
        Click ->
            state ! [ getStrings ]


        Response (Ok strings) ->
            ...


        Response (Err _) ->
            ...


getStrings : Cmd Msg
getStrings =
    Stomp.Proc.init "example.strings"
        |> Stomp.Proc.onResponse Response
        |> Stomp.Client.call server

Remote Procedures

type alias RemoteProcedure msg =
Batch (Proc msg)

Describes a remote procedure call.

init : String -> RemoteProcedure msg

Construct a remote procedure call with the specified command (queue name).

Headers and Payload

withHeader : Header -> RemoteProcedure msg -> RemoteProcedure msg

Add a header to the request message.

withHeaders : List Header -> RemoteProcedure msg -> RemoteProcedure msg

Add multiple headers to the request message.

withPayload : Value -> RemoteProcedure msg -> RemoteProcedure msg

Add a payload to the request message.

Response

onResponse : Callback msg -> RemoteProcedure msg -> RemoteProcedure msg

Set a callback to be triggered when the response message is received.

(Result String a -> msg)
-> Decoder a
-> RemoteProcedure msg
-> RemoteProcedure msg

Set a callback to be triggered when the response message is received and a JSON decoder to be used to decode the message body.

Batching

batch : List (RemoteProcedure msg) -> RemoteProcedure msg

Batch multiple remote procedure calls together.

none : RemoteProcedure msg

Return a remote procedure call that does nothing.