@ably/chat - v1.1.1
    Preparing search index...

    Interface UseTypingResponse

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

    interface UseTypingResponse {
        connectionError?: ErrorInfo;
        connectionStatus: ConnectionStatus;
        currentlyTyping: Set<string>;
        keystroke: () => Promise<void>;
        roomError?: ErrorInfo;
        roomStatus: RoomStatus;
        stop: () => Promise<void>;
    }

    Hierarchy (View Summary)

    Index

    Properties

    connectionError?: ErrorInfo

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

    connectionStatus: ConnectionStatus

    Provides the connection status of the Ably connection.

    currentlyTyping: Set<string>

    A state value representing the set of client IDs that are currently typing in the room. It automatically updates based on typing events received from the room.

    keystroke: () => Promise<void>

    A shortcut to the Typing.keystroke method.

    Sends a typing started event to notify other users that the current user is typing.

    Events are throttled according to the heartbeatThrottleMs room option to prevent excessive network traffic. If called within the throttle interval, the operation becomes a no-op. Multiple rapid calls are serialized to maintain consistency.

    Note:

    • The connection must be in the connected state.
    • Calls to keystroke() and stop() are serialized and resolve in order.
    • The most recent operation always determines the final typing state.
    • The room must be attached to send typing events, typically the ChatRoomProvider handles this automatically.

    This is a stable reference and will not be changed between renders for the same room.

    Type Declaration

    const { keystroke } = useTyping();

    const handleKeyPress = async () => {
    try {
    await keystroke();
    console.log('Typing indicator sent');
    } catch (error) {
    console.error('Failed to send keystroke:', error);
    }
    };
    roomError?: ErrorInfo

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

    roomStatus: RoomStatus

    Provides the status of the room.

    stop: () => Promise<void>

    A shortcut to the Typing.stop method.

    Sends a typing stopped event to notify other users that the current user has stopped typing.

    If the user is not currently typing, this operation is a no-op. Multiple rapid calls are serialized to maintain consistency, with the most recent operation determining the final state.

    Note:

    • The connection must be in the connected state.
    • Calls to keystroke() and stop() are serialized and resolve in order.
    • The room must be attached to send typing events, typically the ChatRoomProvider handles this automatically.

    This is a stable reference and will not be changed between renders for the same room.

    Type Declaration

    const { stop } = useTyping();

    const handleStopTyping = async () => {
    try {
    await stop();
    console.log('Stopped typing indicator');
    } catch (error) {
    console.error('Failed to stop typing:', error);
    }
    };