You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
string that represents the location of the remote resource serving the events/messages.
16
-
> -__param.opts?__: _UseEventSourceProps_
16
+
> -__param.opts?__: _EventSourceInit_
17
17
options to configure the new connection. The possible entries are: __withCredentials__ -> boolean value, defaulting to false, indicating if CORS should be set to include credentials.
Hook for creating and managing a [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) connection to a server, as well as for sending and receiving data on the connection.
the URL to which to connect; this should be the URL to which the WebSocket server will respond.
16
+
> -__param.protocols?__: _UseWebSocketProps_
17
+
either a single protocol string or an array of protocol strings. These strings are used to indicate sub-protocols, so that a single server can implement multiple WebSocket sub-protocols.
18
+
> -__param.binaryType?__: _UseWebSocketProps_
19
+
the type of binary data being received over the WebSocket connection.
function that will be executed when webSocket connection has been opened.
24
+
> -__param.onMessage?__: _UseWebSocketProps_
25
+
function that will be executed when message arrived from webSocket.
26
+
> -__param.onError?__: _UseWebSocketProps_
27
+
function that will be executed when an error occurred.
28
+
> -__param.onClose?__: _UseWebSocketProps_
29
+
function that will be executed when webSocket connection has been closed.
30
+
> -__param.bufferingData?__: _UseWebSocketProps_
31
+
boolean that indicates to use a buffer to keep data sent if connection aren't already opened.
32
+
> -__param.autoReconnect?__: _UseWebSocketProps_
33
+
boolean or object with properties __retries__, __delay__ and __onFailed__. If an error closes connection and its value isn't false or undefined, a connection will be restored every _delay_ milliseconds for __retries__ time: if connection won't be restored __onFailed__ function will be executed if it is present.
34
+
>
35
+
36
+
> ### Returns
37
+
>
38
+
> __result__: _UseWebSocketResult_
39
+
> Object with these properties:
40
+
> -__status__: string rapresenting webSocket state connection: __READY____CONNECTING____OPENED__ or __CLOSED__.
41
+
> -__data__: last data value arrived from webSocket.
42
+
> -__open__: function that opens connection with optional _url_ param .
43
+
> -__send__: function that sends data by webSocket.
44
+
> -__close__: function that closes connection with optional _code_ and _reason_ params.
* **`useEventSource`**: Hook to handle an [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) or [Server-Sent-Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) connection to an HTTP server, which sends events in text/event-stream format.
7
7
* @param {UseEventSourceProps} param - object
8
-
* @param {UseEventSourceProps} param.url - string that represents the location of the remote resource serving the events/messages.
9
-
* @param {UseEventSourceProps} [param.opts] - options to configure the new connection. The possible entries are: __withCredentials__ -> boolean value, defaulting to false, indicating if CORS should be set to include credentials.
10
-
* @param {UseEventSourceProps} [param.events] - array of objects with properties __name__ and __handler__ to listen specified events from source.
11
-
* @param {UseEventSourceProps} [param.immediateConnection] - boolean to start connection immediatly.
12
-
* @param {UseEventSourceProps} [param.onOpen] - function that will be executed when connection is opened.
13
-
* @param {UseEventSourceProps} [param.onError] - function that will be executed when an error occurred.
14
-
* @param {UseEventSourceProps} [param.onMessage] - function that will be executed when a message from without event arrived.
8
+
* @param {string|URL} [param.url] - string that represents the location of the remote resource serving the events/messages.
9
+
* @param {EventSourceInit} [param.opts] - options to configure the new connection. The possible entries are: __withCredentials__ -> boolean value, defaulting to false, indicating if CORS should be set to include credentials.
10
+
* @param {{name: string, handler?:(evt:MessagEvent)=>void}[]} [param.events] - array of objects with properties __name__ and __handler__ to listen specified events from source.
11
+
* @param {boolean} [param.immediateConnection] - boolean to start connection immediatly.
12
+
* @param {(evt: Event)=>void} [param.onOpen] - function that will be executed when connection is opened.
13
+
* @param {(evt: Event)=>void} [param.onError] - function that will be executed when an error occurred.
14
+
* @param {(evt: MessageEvent<T>)=>void} [param.onMessage] - function that will be executed when a message from without event arrived.
15
15
* @returns {UseEventSourceResult} result
16
16
* Object with these properties:
17
-
* - __status__: string rapresenting eventsource state connection: __READY__ __CONNECTING__ __OPENED__ or __CLOSED__
17
+
* - __status__: string rapresenting eventsource state connection: __READY__ __CONNECTING__ __OPENED__ or __CLOSED__.
18
18
* - __data__: last data value arrived from eventSource.
* **`useWebSocket`**: Hook for creating and managing a [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) connection to a server, as well as for sending and receiving data on the connection.
7
+
* @param {UseWebSocketProps} param - object
8
+
* @param {UseWebSocketProps} [param.url] - the URL to which to connect; this should be the URL to which the WebSocket server will respond.
9
+
* @param {UseWebSocketProps} [param.protocols] - either a single protocol string or an array of protocol strings. These strings are used to indicate sub-protocols, so that a single server can implement multiple WebSocket sub-protocols.
10
+
* @param {UseWebSocketProps} [param.binaryType] - the type of binary data being received over the WebSocket connection.
11
+
* @param {UseWebSocketProps} [param.immediateConnection] - boolean to open webSocket connection immediatly.
12
+
* @param {UseWebSocketProps} [param.onOpen] - function that will be executed when webSocket connection has been opened.
13
+
* @param {UseWebSocketProps} [param.onMessage] - function that will be executed when message arrived from webSocket.
14
+
* @param {UseWebSocketProps} [param.onError] - function that will be executed when an error occurred.
15
+
* @param {UseWebSocketProps} [param.onClose] - function that will be executed when webSocket connection has been closed.
16
+
* @param {UseWebSocketProps} [param.bufferingData] - boolean that indicates to use a buffer to keep data sent if connection aren't already opened.
17
+
* @param {UseWebSocketProps} [param.autoReconnect] - boolean or object with properties __retries__, __delay__ and __onFailed__. If an error closes connection and its value isn't false or undefined, a connection will be restored every _delay_ milliseconds for __retries__ time: if connection won't be restored __onFailed__ function will be executed if it is present.
18
+
* @returns {UseWebSocketResult} result
19
+
* Object with these properties:
20
+
* - __status__: string rapresenting webSocket state connection: __READY__ __CONNECTING__ __OPENED__ or __CLOSED__.
21
+
* - __data__: last data value arrived from webSocket.
22
+
* - __open__: function that opens connection with optional _url_ param .
23
+
* - __send__: function that sends data by webSocket.
24
+
* - __close__: function that closes connection with optional _code_ and _reason_ params.
0 commit comments