-
Notifications
You must be signed in to change notification settings - Fork 20
/
documentation.json
231 lines (231 loc) · 14.9 KB
/
documentation.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
[
{
"name": "Phoenix",
"comment": " An Elm client for [Phoenix](http://www.phoenixframework.org) Channels.\n\nThis package makes it easy to connect to Phoenix Channels, but in a more declarative manner than the Phoenix Socket Javascript library. Simply provide a `Socket` and a list of `Channel`s you want to join and this library handles the tedious parts like opening a connection, joining channels, reconnecting after a network error and registering event handlers.\n\n\n#Connect with Phoenix\n@docs connect\n\n# Push messages\n@docs push\n",
"aliases": [],
"types": [],
"values": [
{
"name": "connect",
"comment": " Declare a socket you want to connect to and the channels you want to join. The effect manager will open the socket connection, join the channels. See `Phoenix.Socket` and `Phoenix.Channel` for more configuration and behaviour details.\n\n import Phoenix.Socket as Socket\n import Phoenix.Channel as Channel\n\n type Msg = NewMsg Value | ...\n\n socket =\n Socket.init \"ws://localhost:4000/socket/websocket\"\n\n channel =\n Channel.init \"room:lobby\"\n -- register a handler for messages\n -- with a \"new_msg\" event\n |> Channel.on \"new_msg\" NewMsg\n\n subscriptions model =\n connect socket [channel]\n\n**Note**: An empty channel list keeps the socket connection open.\n",
"type": "Phoenix.Socket.Socket msg -> List (Phoenix.Channel.Channel msg) -> Platform.Sub.Sub msg"
},
{
"name": "push",
"comment": " Pushes a `Push` message to a particular socket address. The address has to be the same as with which you initalized the `Socket` in the `connect` subscription.\n\n payload =\n Json.Encode.object [(\"msg\", \"Hello Phoenix\")]\n\n message =\n Push.init \"room:lobby\" \"new_msg\"\n |> Push.withPayload payload\n\n push \"ws://localhost:4000/socket/websocket\" message\n\n\n**Note**: The message will be queued until you successfully joined a channel to the topic of the message.\n",
"type": "String -> Phoenix.Push.Push msg -> Platform.Cmd.Cmd msg"
}
],
"generated-with-elm-version": "0.18.0"
},
{
"name": "Phoenix.Socket",
"comment": " A socket declares to which endpoint a socket connection should be established.\n\n# Definition\n@docs Socket, AbnormalClose\n\n# Helpers\n@docs init, withParams, heartbeatIntervallSeconds, withoutHeartbeat, reconnectTimer, withDebug, onAbnormalClose, onNormalClose, onOpen, onClose, map\n",
"aliases": [
{
"name": "AbnormalClose",
"comment": " Representation of an Abnormal close.\n",
"args": [],
"type": "{ reconnectAttempt : Int, reconnectWait : Time.Time }"
},
{
"name": "Socket",
"comment": " Representation of a Socket connection\n",
"args": [
"msg"
],
"type": "Phoenix.Socket.PhoenixSocket msg"
}
],
"types": [],
"values": [
{
"name": "heartbeatIntervallSeconds",
"comment": " The client regularly sends a heartbeat to the server. With this function you can specify the intervall in which the heartbeats are send. By default it_s 30 seconds.\n\n init \"ws://localhost:4000/socket/websocket\"\n |> heartbeatIntervallSeconds 60\n",
"type": "Int -> Phoenix.Socket.Socket msg -> Phoenix.Socket.Socket msg"
},
{
"name": "init",
"comment": " Initialize a Socket connection with an endpoint.\n\n init \"ws://localhost:4000/socket/websocket\"\n",
"type": "String -> Phoenix.Socket.Socket msg"
},
{
"name": "map",
"comment": " Composes each callback with the function `a -> b`.\n",
"type": "(a -> b) -> Phoenix.Socket.Socket a -> Phoenix.Socket.Socket b"
},
{
"name": "onAbnormalClose",
"comment": " Set a callback which will be called if the socket connection got closed abnormal, i.e., if the server declined the socket authentication. So this callback is useful for updating query params like access tokens.\n\n type Msg =\n RefreshAccessToken | ...\n\n init \"ws://localhost:4000/socket/websocket\"\n |> withParams [ ( \"accessToken\", \"abc123\" ) ]\n |> onAbnormalClose RefreshAccessToken\n",
"type": "(Phoenix.Socket.AbnormalClose -> msg) -> Phoenix.Socket.Socket msg -> Phoenix.Socket.Socket msg"
},
{
"name": "onClose",
"comment": " Set a callback which will be called if the socket connection got closed. You can learn more about the code [here](https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent).\n",
"type": "({ code : Int, reason : String, wasClean : Bool } -> msg) -> Phoenix.Socket.Socket msg -> Phoenix.Socket.Socket msg"
},
{
"name": "onNormalClose",
"comment": " Set a callback which will be called if the socket connection got closed normal. Useful if you have to do some additional clean up.\n",
"type": "msg -> Phoenix.Socket.Socket msg -> Phoenix.Socket.Socket msg"
},
{
"name": "onOpen",
"comment": " Set a callback which will be called if the socket connection gets open.\n",
"type": "msg -> Phoenix.Socket.Socket msg -> Phoenix.Socket.Socket msg"
},
{
"name": "reconnectTimer",
"comment": " The effect manager will try to establish a socket connection. If it fails it will try again with a specified backoff. By default the effect manager will use the following exponential backoff strategy:\n\n defaultReconnectTimer failedAttempts =\n if backoff < 1 then\n 0\n else\n toFloat (10 * 2 ^ failedAttempts)\n\nWith this function you can specify a custom strategy.\n",
"type": "(Int -> Time.Time) -> Phoenix.Socket.Socket msg -> Phoenix.Socket.Socket msg"
},
{
"name": "withDebug",
"comment": " Enable debug logs for the socket. Every incoming and outgoing message will be printed.\n",
"type": "Phoenix.Socket.Socket msg -> Phoenix.Socket.Socket msg"
},
{
"name": "withParams",
"comment": " Attach parameters to the socket connecton. You can use this to do authentication on the socket level. This will be the first argument (as a map) in your `connect/2` callback on the server.\n\n init \"ws://localhost:4000/socket/websocket\"\n |> withParams [(\"token\", \"GYMXZwXzKFzfxyGntVkYt7uAJnscVnFJ\")]\n",
"type": "List ( String, String ) -> Phoenix.Socket.Socket msg -> Phoenix.Socket.Socket msg"
},
{
"name": "withoutHeartbeat",
"comment": " The client regularly sends a heartbeat to the sever. With this function you can disable the heartbeat.\n\n init \"ws://localhost:4000/socket/websocket\"\n |> withoutHeartbeat\n",
"type": "Phoenix.Socket.Socket msg -> Phoenix.Socket.Socket msg"
}
],
"generated-with-elm-version": "0.18.0"
},
{
"name": "Phoenix.Channel",
"comment": " A channel declares which topic should be joined, registers event handlers and has various callbacks for possible lifecycle events.\n\n# Definition\n@docs Channel\n\n# Helpers\n@docs init, withPayload, on, onJoin, onRequestJoin, onJoinError, onError, onDisconnect, onRejoin, onLeave, onLeaveError, withDebug, map\n@docs init, withPayload, on, onJoin, onRequestJoin, onJoinError, onError, onDisconnect, onRejoin, onLeave, onLeaveError, onPresenceChange, withDebug, map\n\n",
"aliases": [
{
"name": "Channel",
"comment": " Representation of a Phoenix Channel\n",
"args": [
"msg"
],
"type": "Phoenix.Channel.PhoenixChannel msg"
}
],
"types": [],
"values": [
{
"name": "init",
"comment": " Initialize a channel to a given topic.\n\n init \"room:lobby\"\n",
"type": "String -> Phoenix.Channel.Channel msg"
},
{
"name": "map",
"comment": " Composes each callback with the function `a -> b`.\n",
"type": "(a -> b) -> Phoenix.Channel.Channel a -> Phoenix.Channel.Channel b"
},
{
"name": "on",
"comment": " Register an event handler for a event.\n\n type Msg = NewMsg Value | ...\n\n init \"roomy:lobby\"\n |> on \"new_msg\" NewMsg\n",
"type": "String -> (Json.Decode.Value -> msg) -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "onDisconnect",
"comment": " Set a callback which will be called if the socket connection got interrupted. Useful to switch the online status to offline.\n\n type Msg =\n IsOffline | ...\n\n init \"room:lobby\"\n |> onDisconnect IsOffline\n\n**Note**: The effect manager will automatically try to reconnect to the server and to rejoin the channel. See `onRejoin` for details.\n",
"type": "msg -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "onError",
"comment": " Set a callback which will be called if the channel process on the server crashed. The effect manager will automatically rejoin the channel after a crash.\n\n type Msg =\n ChannelCrashed | ...\n\n init \"room:lobby\"\n |> onError ChannelCrashed\n",
"type": "msg -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "onJoin",
"comment": " Set a callback which will be called after you sucessfully joined the channel. It will also be called after you rejoined the channel after a disconnect unless you specified an `onRejoin` handler.\n\n type Msg =\n IsOnline Json.Encode.Value | ...\n\n init \"room:lobby\"\n |> onJoin IsOnline\n",
"type": "(Json.Decode.Value -> msg) -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "onJoinError",
"comment": " Set a callback which will be called if the server declined your request to join the channel.\n\n type Msg =\n CouldNotJoin Json.Encode.Value | ...\n\n init \"room:lobby\"\n |> onJoinError CouldNotJoin\n\n**Note**: If a channel declined a request to join a topic the effect manager won_t try again.\n",
"type": "(Json.Decode.Value -> msg) -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "onLeave",
"comment": " Set a callback which will be called after you sucessfully left a channel.\n\n type Msg =\n LeftLobby Json.Encode.Value | ...\n\n init \"room:lobby\"\n |> onLeave LeftLobby\n",
"type": "(Json.Decode.Value -> msg) -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "onLeaveError",
"comment": " Set a callback which will be called if the server declined your request to left a channel.\n*(It seems that Phoenix v1.2 doesn_t send this)*\n",
"type": "(Json.Decode.Value -> msg) -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "onPresenceChange",
"comment": " Set a callback which will be called when there is a change in the presence state caused by \"presence_state\" and \"presence_diff\" events.\n\n type Msg =\n PresenceChange (Dict String (List Json.Encode.Value)) | ...\n\n init \"room:lobby\"\n |> onPresenceChange PresenceChange\n",
"type": "(Dict.Dict String (List Json.Decode.Value) -> msg) -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "onRejoin",
"comment": " Set a callback which will be called after you sucessfully rejoined the channel after a disconnect. Useful if you want to catch up missed messages.\n\n type Msg =\n IsOnline Json.Encode.Value | ...\n\n init \"room:lobby\"\n |> onRejoin IsOnline\n",
"type": "(Json.Decode.Value -> msg) -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "onRequestJoin",
"comment": " Set a callback which will be called after you request to join the channel.\n\n type Msg =\n JoinLobbyRequested\n\n init \"room:lobby\"\n |> onRequestJoin JoinLobbyRequested\n",
"type": "msg -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "withDebug",
"comment": " Print all status changes.\n",
"type": "Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
},
{
"name": "withPayload",
"comment": " Attach a payload to the join message. You can use this to submit e.g. a user id or authentication infos. This will be the second argument in your `join/3` callback on the server.\n\n payload =\n Json.Encode.object [(\"user_id\", \"123\")]\n\n init \"room:lobby\"\n |> withPayload payload\n",
"type": "Json.Decode.Value -> Phoenix.Channel.Channel msg -> Phoenix.Channel.Channel msg"
}
],
"generated-with-elm-version": "0.18.0"
},
{
"name": "Phoenix.Push",
"comment": " A message to push informations to a channel.\n\n# Definition\n@docs Push\n\n# Helpers\n@docs init, withPayload, onOk, onError, map\n",
"aliases": [
{
"name": "Push",
"comment": " The message abstraction\n",
"args": [
"msg"
],
"type": "Phoenix.Push.PhoenixPush msg"
}
],
"types": [],
"values": [
{
"name": "init",
"comment": " Initialize a message with a topic and an event.\n\n init \"room:lobby\" \"new_msg\"\n",
"type": "Phoenix.Push.Topic -> Phoenix.Push.Event -> Phoenix.Push.Push msg"
},
{
"name": "map",
"comment": " Applies the function on the onOk and onError callback\n",
"type": "(a -> b) -> Phoenix.Push.Push a -> Phoenix.Push.Push b"
},
{
"name": "onError",
"comment": " Callback if the server replies with an \"error\" status.\n\n type Msg = MessageFailed Value | ...\n\n payload =\n Json.Encode.object [(\"msg\", \"Hello Phoenix\")]\n\n init \"room:lobby\" \"new_msg\"\n |> withPayload\n |> onError MessageFailed\n",
"type": "(Json.Encode.Value -> msg) -> Phoenix.Push.Push msg -> Phoenix.Push.Push msg"
},
{
"name": "onOk",
"comment": " Callback if the server replies with an \"ok\" status.\n\n type Msg = MessageArrived | ...\n\n payload =\n Json.Encode.object [(\"msg\", \"Hello Phoenix\")]\n\n init \"room:lobby\" \"new_msg\"\n |> withPayload\n |> onOk (\\_ -> MessageArrived)\n",
"type": "(Json.Encode.Value -> msg) -> Phoenix.Push.Push msg -> Phoenix.Push.Push msg"
},
{
"name": "withPayload",
"comment": " Attach a payload to a message\n\n payload =\n Json.Encode.object [(\"msg\", \"Hello Phoenix\")]\n\n init \"room:lobby\" \"new_msg\"\n |> withPayload\n",
"type": "Json.Encode.Value -> Phoenix.Push.Push msg -> Phoenix.Push.Push msg"
}
],
"generated-with-elm-version": "0.18.0"
}
]