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

    Interface Typing

    This interface is used to interact with typing in a chat room including subscribing to typing events and fetching the current set of typing clients.

    Get an instance via Room.typing.

    interface Typing {
        current(): Set<string>;
        keystroke(): Promise<void>;
        stop(): Promise<void>;
        subscribe(listener: TypingListener): Subscription;
    }
    Index

    Methods

    • Get the current typers, a set of clientIds.

      Returns Set<string>

      The set of clientIds that are currently typing.

    • This will send a typing.started event to the server. Events are throttled according to the heartbeatThrottleMs room option. If an event has been sent within the interval, this operation is no-op.

      Calls to keystroke() and stop() are serialized and will always resolve in the correct order.

      • For example, if multiple keystroke() calls are made in quick succession before the first keystroke() call has sent a typing.started event to the server, followed by one stop() call, the stop() call will execute as soon as the first keystroke() call completes. All intermediate keystroke() calls will be treated as no-ops.
      • The most recent operation (keystroke() or stop()) will always determine the final state, ensuring operations resolve to a consistent and correct state.

      Returns Promise<void>

      A promise which resolves upon success of the operation and rejects with an Ably.ErrorInfo object upon its failure.

      If the Connection is not in the Connected state.

      If the operation fails to send the event to the server.

      If there is a problem acquiring the mutex that controls serialization.

    • This will send a typing.stopped event to the server. If the user was not currently typing, this operation is no-op.

      Calls to keystroke() and stop() are serialized and will always resolve in the correct order.

      • For example, if multiple keystroke() calls are made in quick succession before the first keystroke() call has sent a typing.started event to the server, followed by one stop() call, the stop() call will execute as soon as the first keystroke() call completes. All intermediate keystroke() calls will be treated as no-ops.
      • The most recent operation (keystroke() or stop()) will always determine the final state, ensuring operations resolve to a consistent and correct state.

      Returns Promise<void>

      A promise which resolves upon success of the operation and rejects with an Ably.ErrorInfo object upon its failure.

      If the Connection is not in the Connected state.

      If the operation fails to send the event to the server.

      If there is a problem acquiring the mutex that controls serialization.

    • Subscribe a given listener to all typing events from users in the chat room.

      Parameters

      • listener: TypingListener

        A listener to be called when the typing state of a user in the room changes.

      Returns Subscription

      A response object that allows you to control the subscription to typing events.