Interface UsePresenceResponse

Common status variables for chat features. Most hooks in this library implement this interface.

interface UsePresenceResponse {
    connectionError?: ErrorInfo;
    connectionStatus: ConnectionStatus;
    error?: ErrorInfo;
    isPresent: boolean;
    presence?: Presence;
    roomError?: ErrorInfo;
    roomStatus: RoomStatus;
    update: ((data?: unknown) => Promise<void>);
}

Hierarchy (view full)

Properties

connectionError?: ErrorInfo

If there's a connection error it will be available here.

connectionStatus: ConnectionStatus

Provides the connection status of the Ably connection.

error?: ErrorInfo

Indicates if an error occurred while entering or leaving the room.

isPresent: boolean

Indicates whether the current user is present in the room.

presence?: Presence

Provides access to the underlying Presence instance of the room.

roomError?: ErrorInfo

If there's an error with the room it will be available here.

roomStatus: RoomStatus

Provides the status of the room.

update: ((data?: unknown) => Promise<void>)

A shortcut to the Presence.update method.

Type declaration

    • (data?): Promise<void>
    • Method to update room presence, will emit an update event to all subscribers. If the user is not present, it will be treated as a join event.

      Parameters

      • Optionaldata: unknown

        The users data, a JSON serializable object that will be sent to all subscribers.

      Returns Promise<void>

      or upon failure, the promise will be rejected with an Ably.ErrorInfo object which explains the error.