Interface: Client
client.Client
Hierarchy
-
↳
Client
Properties
dispose
• dispose: () => void
| Promise
<void
>
Type declaration
▸ (): void
| Promise
<void
>
Dispose of the instance and clear up resources.
Returns
void
| Promise
<void
>
Inherited from
Defined in
src/common.ts:57 (opens in a new tab)
Methods
on
▸ on<E
>(event
, listener
): () => void
Listens on the client which dispatches events about the socket state.
Type parameters
Name | Type |
---|---|
E | extends Event |
Parameters
Name | Type |
---|---|
event | E |
listener | EventListener <E > |
Returns
fn
▸ (): void
Listens on the client which dispatches events about the socket state.
Returns
void
Defined in
src/client.ts:433 (opens in a new tab)
subscribe
▸ subscribe<Data
, Extensions
>(payload
, sink
): () => void
Subscribes through the WebSocket following the config parameters. It
uses the sink
to emit received data or errors. Returns a cleanup
function used for dropping the subscription and cleaning stuff up.
Type parameters
Name | Type |
---|---|
Data | Record <string , unknown > |
Extensions | unknown |
Parameters
Name | Type |
---|---|
payload | SubscribePayload |
sink | Sink <ExecutionResult <Data , Extensions >> |
Returns
fn
▸ (): void
Subscribes through the WebSocket following the config parameters. It
uses the sink
to emit received data or errors. Returns a cleanup
function used for dropping the subscription and cleaning stuff up.
Returns
void
Defined in
src/client.ts:439 (opens in a new tab)
terminate
▸ terminate(): void
Terminates the WebSocket abruptly and immediately.
A close event 4499: Terminated
is issued to the current WebSocket and an
artificial { code: 4499, reason: 'Terminated', wasClean: false }
close-event-like
object is immediately emitted without waiting for the one coming from WebSocket.onclose
.
Terminating is not considered fatal and a connection retry will occur as expected.
Useful in cases where the WebSocket is stuck and not emitting any events; can happen on iOS Safari, see: https://github.com/enisdenjo/graphql-ws/discussions/290 (opens in a new tab).
Returns
void