@ovok/native/socket
Realtime socket provider and context.
- Stable unknown
- Release candidate since 1.16.1-rc.3
- Development since 1.16.1-dev.2111+9796905
Realtime socket provider and context.
Import from @ovok/native/socket.
Components
SocketProvider()
function SocketProvider(__namedParameters): Element;Connects a Socket.IO client authenticated with the current session and shares it with descendants.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | SocketProviderProps |
Returns
Element
Hooks
useAiEventListener()
function useAiEventListener(): object;Subscribes to AI session events delivered over the socket.
Returns
subscribe(type, callback), which returns a function that removes the subscription.
| Name | Type | Description |
|---|---|---|
subscribe() | (type, callback) => () => boolean | undefined | Registers a callback for an event type; returns a function that unsubscribes it. |
useSocket()
function useSocket(): SocketContextType;Returns the socket and its connection state; must be used within a SocketProvider.
Returns
Type Aliases
SocketContextType
type SocketContextType = object;Value of the socket context.
Properties
isConnected
isConnected: boolean;Whether the socket is currently connected.
socket
socket: ReturnType<typeof io> | null;The Socket.IO client, or null before it is created.
SocketLogPayload
type SocketLogPayload = object;Log message received over the socket.
Properties
level
level: "info" | "warn" | "error";Severity of the message.
message
message: string;Log text.
Variables
SocketContext
const SocketContext: Context<SocketContextType | null>;Context holding the socket and its connection state.
Last updated on