Skip to content

API reference / @chanx-js/client / core / ControllerOptions

Interface: ControllerOptions<Address, ToClient> ​

Defined in: packages/client/src/core/controller.ts:28

Extends ​

Type Parameters ​

Type Parameter
Address extends string
ToClient extends ChanxMessage

Properties ​

buffer? ​

ts
optional buffer?: BufferMode;

Defined in: packages/client/src/core/controller.ts:33


closeDelay? ​

ts
optional closeDelay?: number;

Defined in: packages/client/src/core/socket.ts:59

Grace period before a socket with no remaining consumers is actually closed. React's StrictMode unmounts and immediately remounts in development, which would otherwise tear down and rebuild the connection on every mount.

Inherited from ​

ConnectOptions.closeDelay


enabled? ​

ts
optional enabled?: boolean;

Defined in: packages/client/src/core/controller.ts:32


heartbeat? ​

ts
optional heartbeat?: false | HeartbeatOptions;

Defined in: packages/client/src/core/socket.ts:50

Ping on an interval and reconnect if nothing comes back. Off unless enabled: chanx consumers only answer ping when they declare a handler for it, and one that does not replies with an error frame every interval. connect() turns it on for channels whose schema declares ping/pong.

Inherited from ​

ConnectOptions.heartbeat


maxQueuedFrames? ​

ts
optional maxQueuedFrames?: number;

Defined in: packages/client/src/core/socket.ts:52

Cap on frames buffered while the socket is not yet open.

Inherited from ​

ConnectOptions.maxQueuedFrames


on? ​

ts
optional on?: HandlerMap<ToClient>;

Defined in: packages/client/src/core/controller.ts:36


onError? ​

ts
optional onError?: (error) => void;

Defined in: packages/client/src/core/controller.ts:37

Parameters ​

ParameterType
errorChanxErrorFrame

Returns ​

void


only? ​

ts
optional only?: readonly ToClient["action"][];

Defined in: packages/client/src/core/controller.ts:35

Restrict which actions reach the buffer. Handlers in on are unaffected.


onReconnectStop? ​

ts
optional onReconnectStop?: (attempts) => void;

Defined in: packages/client/src/core/socket.ts:43

Parameters ​

ParameterType
attemptsnumber

Returns ​

void

Inherited from ​

ConnectOptions.onReconnectStop


onUnhandled? ​

ts
optional onUnhandled?: (message, envelope) => void;

Defined in: packages/client/src/core/controller.ts:42

Messages nothing took: no on handler, and kept out of the buffer by only or buffer: 'none'.

Parameters ​

ParameterType
messageToClient
envelopeEnvelope

Returns ​

void


params? ​

ts
optional params?: ParamsOf<Address>;

Defined in: packages/client/src/core/client.ts:21

Inherited from ​

ConnectOptions.params


protocols? ​

ts
optional protocols?: string | string[];

Defined in: packages/client/src/core/socket.ts:30

Inherited from ​

ConnectOptions.protocols


queryParams? ​

ts
optional queryParams?: Record<string, string | number>;

Defined in: packages/client/src/core/socket.ts:31

Inherited from ​

ConnectOptions.queryParams


reconnectAttempts? ​

ts
optional reconnectAttempts?: number;

Defined in: packages/client/src/core/socket.ts:39

Inherited from ​

ConnectOptions.reconnectAttempts


reconnectInterval? ​

ts
optional reconnectInterval?: number | ((attempt) => number);

Defined in: packages/client/src/core/socket.ts:41

Fixed delay, or a function of the attempt number for backoff.

Inherited from ​

ConnectOptions.reconnectInterval


retryOnError? ​

ts
optional retryOnError?: boolean;

Defined in: packages/client/src/core/socket.ts:42

Inherited from ​

ConnectOptions.retryOnError


share? ​

ts
optional share?: boolean;

Defined in: packages/client/src/core/socket.ts:37

Share one socket per resolved URL. connect() defaults it to true for channels that carry topics and false otherwise: topic frames are routed per consumer, but on a plain channel every consumer of a shared socket sees every reply.

Inherited from ​

ConnectOptions.share


shouldReconnect? ​

ts
optional shouldReconnect?: (event) => boolean;

Defined in: packages/client/src/core/socket.ts:38

Parameters ​

ParameterType
event{ code?: number; reason?: string; }
event.code?number
event.reason?string

Returns ​

boolean

Inherited from ​

ConnectOptions.shouldReconnect


socketFactory? ​

ts
optional socketFactory?: SocketFactory;

Defined in: packages/client/src/core/socket.ts:53

Inherited from ​

ConnectOptions.socketFactory


validate? ​

ts
optional validate?: ValidateConfig;

Defined in: packages/client/src/core/client.ts:22

Inherited from ​

ConnectOptions.validate

MIT licensed