diff --git a/content/chat/rooms/typing.textile b/content/chat/rooms/typing.textile index 59dc51a51b..129f9b86af 100644 --- a/content/chat/rooms/typing.textile +++ b/content/chat/rooms/typing.textile @@ -72,6 +72,10 @@ The following is the structure of a typing event: "clemons", "zoranges", }, + "change": { + "type": "typing.started", + "clientId": "clemons" + } } ``` @@ -79,6 +83,9 @@ The following are the properties of a typing event: |_. Property |_. Description |_. Type | | currentlyTyping | A set of all users currently typing. | Set | +| change | The single change that resulted in the event. | Object | +| | type: The type of change that occurred. | String | +| | clientId: The @clientId@ of the user that triggered the change. | String | You can use the size of the @currentlyTyping@ set to decide whether to display individual user names, or that multiple people are typing in your user interface. @@ -99,8 +106,9 @@ blang[react]. blang[javascript,kotlin]. ```[javascript] // Initial subscription - const { unsubscribe } = room.typing.subscribe((event) => { - console.log(`${event.clientId} is currently typing...`); + import { TypingEvent } from '@ably/chat'; + const { unsubscribe } = room.typing.subscribe((event: TypingEvent) => { + console.log('Typing event received: ', event); }); // To remove the listener @@ -125,30 +133,28 @@ blang[react,swift,kotlin]. h2(#set). Set typing status blang[javascript,swift,kotlin]. - Use the "@typing.start()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Typing.html#start"@typing.start()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/typing/start%28%29"@typing.start()@":https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat-android/com.ably.chat/-typing/start.html method to emit a typing event with @isTyping@ set to @true@. + Use the "@typing.keystroke()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Typing.html#start"@typing.start()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/typing/start%28%29"@typing.start()@":https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat-android/com.ably.chat/-typing/start.html method to emit a typing event with @type@ set to @typing.started@. blang[react]. - Use the "@start()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-react.UseTypingResponse.html#start method available from the response of the @useTyping@ hook to emit an event when a user has started typing. - -There is a timeout associated with start events. A stop event will be automatically emitted after it expires if one isn't received before the timeout. The length of this timeout is customizable using the @timeoutMs@ parameter that can be configured in the @RoomOptions@ that you set when you "create a room":/docs/chat/rooms#create. The default is 10000ms. + Use the "@keystroke()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-react.UseTypingResponse.html#keystroke method available from the response of the @useTyping@ hook to emit an event when a user has started typing. ```[javascript] -await room.typing.start(); +await room.typing.keystroke(); ``` ```[react] import { useTyping } from '@ably/chat'; const MyComponent = () => { - const { start, currentlyTyping, error } = useTyping(); - const handleStartClick = () => { - start(); + const { keystroke, currentlyTyping, error } = useTyping(); + const handleKeystrokeClick = () => { + keystroke(); }; return (
Typing Error: {error.message}
} - +Currently typing: {currentlyTyping.join(', ')}