[{"name":"Channel","comment":" This module is for working directly with channels.\n\nBefore you can join a channel and start sending and receiving, you first need\nto [connect to a socket](Socket).\n\n\n# Sending Messages\n\n@docs send, EventOut, JoinConfig, PushConfig, EventConfig, LeaveConfig\n\n@docs PortOut, PackageOut\n\n\n# Receiving Messages\n\n@docs subscriptions, EventIn, Topic, PushEvent\n\n@docs PortIn, PackageIn\n\n","unions":[{"name":"EventIn","comment":" All of the events you can receive from the channel.\n\nIf you are using more than one channel, then you can check `Topic` to determine\nwhich channel the [EventIn](#EventIn) relates to. If you are only using a single\nchannel, you can ignore `Topic`.\n\n`InvalidEvent` means that an event has been received from the accompanying JS\nthat cannot be handled. This should not happen, if it does, please raise an\n[issue](https://github.com/phollyer/elm-phoenix-websocket/issues).\n\n","args":[],"cases":[["JoinOk",["Channel.Topic","Json.Encode.Value"]],["JoinError",["Channel.Topic","Json.Encode.Value"]],["JoinTimeout",["Channel.Topic"]],["PushOk",["Channel.Topic","Channel.PushEvent","Json.Encode.Value"]],["PushError",["Channel.Topic","Channel.PushEvent","Json.Encode.Value"]],["PushTimeout",["Channel.Topic","Channel.PushEvent"]],["Message",["Channel.Topic","Channel.PushEvent","Json.Encode.Value"]],["Error",["Channel.Topic","Json.Encode.Value"]],["LeaveOk",["Channel.Topic"]],["Closed",["Channel.Topic"]],["InvalidEvent",["Channel.Topic","String.String","Json.Encode.Value"]]]},{"name":"EventOut","comment":" All of the events you can send to the channel.\n\nEach of these [EventOut](#EventOut) messages corresponds to the equivalent function\nin the [PhoenixJS API](https://hexdocs.pm/phoenix/js/index.html#channel). For\nmore info on these please read the API\n[docs](https://hexdocs.pm/phoenix/js/index.html#channel).\n\n","args":[],"cases":[["Join",["Channel.JoinConfig"]],["Push",["Channel.PushConfig"]],["On",["Channel.EventConfig"]],["Off",["Channel.EventConfig"]],["Leave",["Channel.LeaveConfig"]]]}],"aliases":[{"name":"EventConfig","comment":" A type alias representing channel events that can be turned [On](#EventOut)\nor [Off](#EventOut).\n\n`topic` - optional channel topic id, for example: `Just \"topic:subtopic\"`.\n\nThe `topic` is used to track the channels on the JS side. This allows for\nutilising multiple channels. Setting `topic = Nothing` will set the event on\nthe last used channel, or the only channel you're using if using only one\nchannel.\n\n`event` - the event that you want to be turned [On](#EventOut) or\n[Off](#EventOut).\n\nIn order to receive event [Message](#EventIn)s, they need to be registered with\nan [On](#EventOut) event sent to the channel. So if your Phoenix Channel is\ngoing to `push` or `broadcast` a `new_msg` event, it needs to be registered as\nfollows:\n\n    import Ports.Phoenix as Phx\n    import Channel\n\n    Phx.sendMessage\n        |> Channel.send\n            (On\n                { topic = Just \"topic:subtopic\"\n                , event = \"new_msg\"\n                }\n            )\n\nNow you will be able to receive `new_msg`s as follows:\n\n    import Channel exposing (EventIn(..))\n\n    type Msg\n        = ChannelMsg Channel.EventIn\n\n    update : Msg -> Model -> (Model, Cmd Msg)\n    update msg model =\n        case msg of\n            ChannelMsg (Message \"topic:subtopic\" \"new_msg\" payload) ->\n                ...\n\n    subscriptions : Model -> Sub Msg\n    subscriptions _ =\n        Phx.channelReceiver\n            |> Channel.subscriptions\n                ChannelMsg\n\n**NB** you must set your [On](#EventOut) events after you have joined the\nrelevant channel.\n\n","args":[],"type":"{ topic : Maybe.Maybe String.String, event : String.String }"},{"name":"JoinConfig","comment":" A type alias representing the settings for joining a channel.\n\n`topic` - the channel topic id, for example: `\"topic:subtopic\"`.\n\n`timeout` - optional timeout, in ms, before retrying to join if the previous\nattempt failed.\n\n`payload` - optional data to be sent to the channel when joining.\n\n","args":[],"type":"{ topic : String.String, timeout : Maybe.Maybe Basics.Int, payload : Maybe.Maybe Json.Encode.Value }"},{"name":"LeaveConfig","comment":" A type alias representing the settings for leaving a channel.\n\n`topic` - optional channel topic id, for example: `Just \"topic:subtopic\"`.\n\nThe `topic` is used to track the channels on the JS side. This allows for\nutilising multiple channels. Setting `topic = Nothing` will leave the last used\nchannel, or the only channel you're using if using only one channel.\n\n`timeout` - optional timeout, in ms, before retrying to leave if the previous\nattempt failed.\n\n","args":[],"type":"{ topic : Maybe.Maybe String.String, timeout : Maybe.Maybe Basics.Int }"},{"name":"PackageIn","comment":" A type alias representing the data received from a channel. You will not\nuse this directly.\n","args":[],"type":"{ topic : String.String, event : String.String, payload : Json.Encode.Value }"},{"name":"PackageOut","comment":" A type alias representing the data sent out through a `port` to a channel.\nYou will not use this directly.\n","args":[],"type":"{ target : String.String, event : String.String, payload : Json.Encode.Value }"},{"name":"PortIn","comment":" A type alias representing the `port` function required to receive\nthe [EventIn](#EventIn) from the channel.\n\nYou could write this yourself, if you do, it needs to be named\n`channelReceiver`, although you may find it simpler to just add\n[this port module](https://github.com/phollyer/elm-phoenix-websocket/blob/master/src/Ports/Phoenix.elm)\nto your `src` - it includes all the necessary `port` functions.\n\n","args":["msg"],"type":"(Channel.PackageIn -> msg) -> Platform.Sub.Sub msg"},{"name":"PortOut","comment":" A type alias representing the `port` function required to send the\n[EventOut](#EventOut) to the channel.\n\nYou could write this yourself, if you do, it needs to be named\n`sendMessage`, although you may find it simpler to just add\n[this port module](https://github.com/phollyer/elm-phoenix-websocket/blob/master/src/Ports/Phoenix.elm)\nto your `src` - it includes all the necessary `port` functions.\n\n","args":["msg"],"type":"Channel.PackageOut -> Platform.Cmd.Cmd msg"},{"name":"PushConfig","comment":" A type alias representing the settings for pushing messages over a channel.\n\n`topic` - the channel topic id, for example: `Just \"topic:subtopic\"`.\n\nThe `topic` is used to track the channels on the JS side. This allows for\nutilising multiple channels. Setting `topic = Nothing` will send the push over\nthe last used channel, or the only channel you're using if using only one\nchannel.\n\n`event` - the event to send to the channel.\n\n`timeout` - optional timeout, in ms, before retrying to push if the previous\nattempt failed.\n\n`payload` - the data to be sent.\n\n","args":[],"type":"{ topic : Maybe.Maybe String.String, event : String.String, timeout : Maybe.Maybe Basics.Int, payload : Json.Encode.Value }"},{"name":"PushEvent","comment":" A type alias representing a [Push](#EventOut) to a channel. Use this to\nidentify which [Push](#EventOut) an [EventIn](#EventIn) relates to.\n","args":[],"type":"String.String"},{"name":"Topic","comment":" A type alias representing the channel topic. Use this to identify the\nchannel an [EventIn](#EventIn) relates to.\n\nIf you are only using one channel, you can ignore this.\n\n","args":[],"type":"String.String"}],"values":[{"name":"send","comment":" Send an [EventOut](#EventOut) to the channel.\n\n    import Channel exposing (EventOut(..))\n    import Ports.Phoenix as Phx\n\n    -- Join a Channel\n\n    Phx.sendMessage\n      |> Channel.send\n        (Join\n          { topic = \"topic:subtopic\"\n          , timeout = Nothing\n          , payload = Nothing\n          }\n        )\n\n    -- Push some data to a Channel\n\n    import Json.Encode as JE\n\n    Phx.sendMessage\n      |> Channel.send\n        (Push\n          { topic = Just \"topic:subtopic\"\n          , event = \"send_msg\"\n          , timeout = Nothing\n          , data =\n              JE.object\n                [ (\"msg\", \"Hello to everyone!\" |> JE.string) ]\n          }\n\n","type":"Channel.EventOut -> Channel.PortOut msg -> Platform.Cmd.Cmd msg"},{"name":"subscriptions","comment":" Subscribe to receive incoming channel events.\n\n    import Channel\n    import Ports.Phoenix as Phx\n\n    type Msg\n      = ChannelMsg Channel.EventIn\n      | ...\n\n\n    subscriptions : Model -> Sub Msg\n    subscriptions _ =\n        Phx.channelReceiver\n          |> Channel.subscriptions\n            ChannelMsg\n\n","type":"(Channel.EventIn -> msg) -> Channel.PortIn msg -> Platform.Sub.Sub msg"}],"binops":[]},{"name":"Presence","comment":" This module is for working with Phoenix\n[Presence](https://hexdocs.pm/phoenix/1.5.3/Phoenix.Presence.html#content).\n\nBefore you can receive presence information, you first need to\n[connect to a socket](Socket) and [join a channel](Channel). Once this is done,\nyou can then [subscribe](#subscribe) to start receiving [Presence](#Presence)\ndata as your users come and go.\n\nIf you are new to Phoenix Presence, you will need to setup your backend\nchannel as described\n[here](https://hexdocs.pm/phoenix/1.5.3/Phoenix.Presence.html#content).\nCurrently, only the `metas` key is supported.\n\n\n# Receiving Messages\n\n@docs subscriptions, EventIn, Topic, Presence, PresenceState, PresenceDiff\n\n@docs PortIn, Package\n\n\n# Decoders\n\n@docs decodeMetas\n\n","unions":[{"name":"EventIn","comment":" All of the presence events that can come from the channel.\n\nIf you are using more than one channel, then you can check `Topic` to determine\nwhich channel the [EventIn](#EventIn) relates to. If you are only using a single\nchannel, you can ignore `Topic`.\n\n`InvalidEvent` means that an event has been received from the accompanying JS\nthat cannot be handled. This should not happen, if it does, please raise an\n[issue](https://github.com/phollyer/elm-phoenix-websocket/issues).\n\n","args":[],"cases":[["Join",["Presence.Topic","Presence.Presence"]],["Leave",["Presence.Topic","Presence.Presence"]],["State",["Presence.Topic","Presence.PresenceState"]],["Diff",["Presence.Topic","Presence.PresenceDiff"]],["InvalidEvent",["Presence.Topic","String.String"]]]}],"aliases":[{"name":"Package","comment":" A type alias representing the data received from a channel. You will not\nuse this directly.\n","args":[],"type":"{ topic : String.String, event : String.String, payload : Json.Encode.Value }"},{"name":"PortIn","comment":" A type alias representing the `port` function required to receive\nthe [EventIn](#EventIn) from the channel.\n\nYou could write this yourself, if you do, it needs to be named\n`presenceReceiver`, although you may find it simpler to just add\n[this port module](https://github.com/phollyer/elm-phoenix-websocket/blob/master/src/Ports/Phoenix.elm)\nto your `src` - it includes all the necessary `port` functions.\n\n","args":["msg"],"type":"(Presence.Package -> msg) -> Platform.Sub.Sub msg"},{"name":"Presence","comment":" A type alias representing a\n[Presence](https://hexdocs.pm/phoenix/1.5.3/Phoenix.Presence.html#content).\n","args":[],"type":"{ id : String.String, metas : List.List Json.Decode.Value }"},{"name":"PresenceDiff","comment":" A type alias representing the `joins` and `leaves` on the channel as they\nhappen.\n","args":[],"type":"{ joins : List.List Presence.Presence, leaves : List.List Presence.Presence }"},{"name":"PresenceState","comment":" A type alias representing a list of all [Presence](#Presence)s stored on\nthe channel.\n","args":[],"type":"List.List Presence.Presence"},{"name":"Topic","comment":" A type alias representing the channel topic. Use this to identify the\nchannel an [EventIn](#EventIn) relates to.\n\nIf you are only using one channel, you can ignore this.\n\n","args":[],"type":"String.String"}],"values":[{"name":"decodeMetas","comment":" Decode the metas for a Presence.\n\nOnly you will know what `meta` information you are storing, so you will need to\nprovide your own decoder.\n\n","type":"Json.Decode.Decoder a -> List.List Json.Decode.Value -> List.List a"},{"name":"subscriptions","comment":" Subscribe to receive incoming presence events.\n\n    import Presence\n    import Ports.Phoenix as Phx\n\n    type Msg\n      = PresenceMsg Presence.EventIn\n      | ...\n\n\n    subscriptions : Model -> Sub Msg\n    subscriptions _ =\n        Phx.presenceReceiver\n          |> Presence.subscriptions\n            PresenceMsg\n\n","type":"(Presence.EventIn -> msg) -> Presence.PortIn msg -> Platform.Sub.Sub msg"}],"binops":[]},{"name":"Socket","comment":" This module is for working directly with the socket.\n\nOnce you have connected to the socket, you will then need to\n[join a channel](Channel).\n\n\n# Sending Messages\n\n@docs send, EventOut\n\n@docs PortOut, PackageOut\n\n\n# Connecting With Options\n\nThis enables finer control over the socket if you want to adjust the default\nsettings.\n\n@docs connectOptions\n\n_Not all options are available on all versions of_\n_[PhoenixJS](https://hexdocs.pm/phoenix/js), so check the docs at <https://hexdocs.pm/phoenix/{vesion}/js>_\n_if something isn't working as expected._\n\nAnd please raise an\n[issue](https://github.com/phollyer/elm-phoenix-websocket/issues) if you find\nthat an option doesn't behave as it should.\n\n@docs ConnectOptions\n\n\n# Receiving Messages\n\n@docs subscriptions, EventIn, MessageConfig\n\n@docs PortIn, PackageIn\n\n","unions":[{"name":"EventIn","comment":" All of the events you can receive from the socket.\n\nYou will probably be most interested in `Opened`,\n`Closed` and `Error`.\n\nThe data each [EventIn](#EventIn) carries should be self explanatory,\nexcept for maybe:\n\n`HasLoggerReply` - not all versions of\n[PhoenixJS](https://hexdocs.pm/phoenix/js) have the `hasLogger` function.\nTherefore, a value of `Nothing` means the function does not exist, while a\n`Just` will carry the result of calling `hasLogger` on the socket.\n\n`InvalidEvent` means that an event has been received from the accompanying JS\nthat cannot be handled. This should not happen, if it does, please raise an\n[issue](https://github.com/phollyer/elm-phoenix-websocket/issues).\n\n","args":[],"cases":[["Opened",[]],["Closed",[]],["Error",["String.String"]],["Message",["Socket.MessageConfig"]],["ConnectionStateReply",["String.String"]],["EndPointURLReply",["String.String"]],["HasLoggerReply",["Maybe.Maybe Basics.Bool"]],["IsConnectedReply",["Basics.Bool"]],["MakeRefReply",["String.String"]],["ProtocolReply",["String.String"]],["InvalidEvent",["String.String"]]]},{"name":"EventOut","comment":" All of the events you can send to the socket.\n\nYou will probably be most interested in `Connect`,\n`ConnectWithOptions` and `Disconnect`.\n\nEach of these [EventOut](#EventOut) messages corresponds to the equivalent function\nin the [PhoenixJS API](https://hexdocs.pm/phoenix/js/index.html#socket). For\nmore info on these please read the API\n[docs](https://hexdocs.pm/phoenix/js/index.html#socket).\n\n","args":[],"cases":[["Connect",["Maybe.Maybe Json.Encode.Value"]],["ConnectWithOptions",["Socket.ConnectOptions","Maybe.Maybe Json.Encode.Value"]],["Disconnect",[]],["ConnectionState",[]],["EndPointURL",[]],["HasLogger",[]],["IsConnected",[]],["MakeRef",[]],["Protocol",[]],["Log",["{ kind : String.String, msg : String.String, data : Json.Decode.Value }"]]]}],"aliases":[{"name":"ConnectOptions","comment":" A type alias representing the options that can be set on the socket when\ninstantiating a `new Socket(url, options)` on the JS side.\n\nSee <https://hexdocs.pm/phoenix/js/#socket> for more info on the options and\nthe effect they have. All the option types are `Maybe`'s of the equivalent\nJS types, with two exceptions:\n\n1.  reconnectAfterMS\n2.  rejoinAfterMs\n\nOn the JS side, these take an `Int` or a `function` that returns an `Int`. But\nbecause we can't send functions through ports, you can set the `...MaxBackOff`\nand `...SteppedBackOff` values as follows:\n\n    { connectOptions\n        | reconnectSteppedBackOff = [ 10, 20, 50, 100, 500 ]\n        , reconnectMaxBackOff = 1000\n    }\n\n    { connectOptions\n        | rejoinSteppedBackOff = [ 1000, 2000, 5000 ]\n        , rejoinMaxBackOff = 10000\n    }\n\nOn the JS side, this results in:\n\n    { reconnectAfterMs: function(tries){ return [10, 20, 50, 100, 500][tries - 1] || 1000 }}\n\n    { rejoinAfterMs: function(tries){ return [1000, 2000, 5000][tries - 1] || 10000 }}\n\n","args":[],"type":"{ transport : Maybe.Maybe String.String, timeout : Maybe.Maybe Basics.Int, heartbeatIntervalMs : Maybe.Maybe Basics.Int, reconnectAfterMs : Maybe.Maybe Basics.Int, reconnectMaxBackOff : Maybe.Maybe Basics.Int, reconnectSteppedBackoff : Maybe.Maybe (List.List Basics.Int), rejoinAfterMs : Maybe.Maybe Basics.Int, rejoinMaxBackOff : Maybe.Maybe Basics.Int, rejoinSteppedBackoff : Maybe.Maybe (List.List Basics.Int), longpollerTimeout : Maybe.Maybe Basics.Int, binaryType : Maybe.Maybe String.String }"},{"name":"MessageConfig","comment":" A type alias representing the raw message received by the socket. This\narrives as an [EventIn](#EventIn) `Message`.\n\nYou will need to decode `payload` yourself, as only you will know the structure\nof this `Value`. It will be whatever data has been sent back from Phoenix\ncorresponding to `event` so you will need to check this in order to select the\ncorrect decoder if you are sending different structures for different `event`s.\n\nIf you are using multiple channels, you will also need to check the `topic` to\nidentify the channel that sent the `event`.\n\nYou won't need this if you choose to handle messages over\n[Channel](Channel#MsgIn)s.\n\n","args":[],"type":"{ joinRef : Maybe.Maybe String.String, ref : Maybe.Maybe String.String, topic : String.String, event : String.String, payload : Json.Encode.Value }"},{"name":"PackageIn","comment":" A type alias representing the data received from the socket. You will not\nuse this directly.\n","args":[],"type":"{ event : String.String, payload : Json.Encode.Value }"},{"name":"PackageOut","comment":" A type alias representing the data sent out through the `port` to the socket.\nYou will not use this directly.\n","args":[],"type":"{ target : String.String, event : String.String, payload : Json.Encode.Value }"},{"name":"PortIn","comment":" A type alias representing the `port` function required to receive\nthe [EventIn](#EventIn) from the socket.\n\nYou could write this yourself, if you do, it needs to be named\n`socketReceiver`, although you may find it simpler to just add\n[this port module](https://github.com/phollyer/elm-phoenix-websocket/blob/master/src/Ports/Phoenix.elm)\nto your `src` - it includes all the necessary `port` functions.\n\n","args":["msg"],"type":"(Socket.PackageIn -> msg) -> Platform.Sub.Sub msg"},{"name":"PortOut","comment":" A type alias representing the `port` function required to send the\n[EventOut](#EventOut) to the socket.\n\nYou could write this yourself, if you do, it needs to be named\n`sendMessage`, although you may find it simpler to just add\n[this port module](https://github.com/phollyer/elm-phoenix-websocket/blob/master/src/Ports/Phoenix.elm)\nto your `src` - it includes all the necessary `port` functions.\n\n","args":["msg"],"type":"Socket.PackageOut -> Platform.Cmd.Cmd msg"}],"values":[{"name":"connectOptions","comment":" A helper function to return a [ConnectOptions](#ConnectOptions) record with\n`Nothing` set on everything. Use it as a starting point for setting just the\noptions you want.\n\n    { connectOptions | timeout = Just 10000 }\n\n","type":"Socket.ConnectOptions"},{"name":"send","comment":" Send an [EventOut](#EventOut) to the socket.\n\n    import Ports.Phoenix as Phx\n    import Socket exposing (EventOut(..))\n\n    -- Connect to the Socket\n\n    Phx.sendMessage\n      |> Socket.send\n        (Connect Nothing)\n\n    -- Disconnect from the Socket\n\n    Phx.sendMessage\n      |> Socket.send\n        Disconnect\n\n","type":"Socket.EventOut -> Socket.PortOut msg -> Platform.Cmd.Cmd msg"},{"name":"subscriptions","comment":" Subscribe to receive incoming socket events.\n\n    import Ports.Phoenix as Phx\n    import Socket\n\n    type Msg\n      = SocketMsg Socket.EventIn\n      | ...\n\n\n    subscriptions : Model -> Sub Msg\n    subscriptions _ =\n        Phx.socketReceiver\n          |> Socket.subscriptions\n            SocketMsg\n\n","type":"(Socket.EventIn -> msg) -> Socket.PortIn msg -> Platform.Sub.Sub msg"}],"binops":[]}]