@ably/chat - v0.14.1
    Preparing search index...

    Interface UsePresenceParams

    The options for the usePresence hook.

    interface UsePresenceParams {
        autoEnterLeave?: boolean;
        initialData?: JsonObject;
        onConnectionStatusChange?: (change: ConnectionStatusChange) => void;
        onDiscontinuity?: DiscontinuityListener;
        onRoomStatusChange?: (change: RoomStatusChange) => void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    autoEnterLeave?: boolean

    Controls whether the hook should automatically enter presence when the component mounts and the room becomes attached, and automatically leave presence when the component unmounts.

    Also controls whether the hook will automatically re-enter presence if the room is detached and then re-attached.

    Important If UsePresenceResponse.leave is called, then the hook will NOT auto-enter. To re-enable auto-enter behavior, you must call UsePresenceResponse.enter or UsePresenceResponse.update. When set to false, you have full manual control over entering and leaving presence.

    Defaults to true if not provided.

    true
    
    initialData?: JsonObject

    The initial data to enter the room with when auto-entering (autoEnterLeave=true). Any JSON serializable data can be provided. This data is only used for the initial auto-enter when the component mounts. Changes to this value after the first render are ignored. To update presence data after the initial enter, use the update or enter methods returned by the hook.

    // This will cause the hook to auto-enter presence with the provided data
    // autoEnterLeave is implicitly true
    const { presence, update } = usePresence({
    initialData: { status: 'online', lastSeen: Date.now() }
    });

    // Subsequent data updates must be done via calls to enter/update
    await update({status: 'away'});
    undefined
    
    onConnectionStatusChange?: (change: ConnectionStatusChange) => void

    Register a callback for when the connection status to Ably changes.

    Type Declaration

    onDiscontinuity?: DiscontinuityListener

    Register a callback to detect and respond to discontinuities. For example, you might choose to fetch missing messages.

    The error that caused the discontinuity.

    onRoomStatusChange?: (change: RoomStatusChange) => void

    Register a callback for when the room status changes.

    Type Declaration