Publish an annotation removal request for a message, to remove it from the message's annotation summary. The semantics of a delete, and the fields it requires, differ by annotation type.
It sets action to annotation.delete on the annotation object you pass, overwriting any action you set.
The supplied Message must carry a populated serial. A newly constructed Message has none, so the call rejects with an ErrorInfo.
Message annotations must be enabled for the channel's namespace by a rule, and the key or token must have the annotation-publish capability. Without either the server rejects the operation, so the call rejects with an ErrorInfo.
Does not implicitly attach the channel. It rejects with an ErrorInfo on a channel in the failed or suspended state, or when the connection is unusable.
The message which has an annotation that you want to delete.
The annotation deletion request. It must include at least the type. Other required fields depend on the type.
A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.
await channel.annotations.delete(message, { type: 'emoji:distinct.v1', name: '👍' });
https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-delete
Publish an annotation removal request for a message, to remove it from the message's annotation summary. The semantics of a delete, and the fields it requires, differ by annotation type.
It sets action to annotation.delete on the annotation object you pass, overwriting any action you set.
The supplied serial must be a non-empty string, otherwise the call rejects with an ErrorInfo.
Message annotations must be enabled for the channel's namespace by a rule, and the key or token must have the annotation-publish capability. Without either the server rejects the operation, so the call rejects with an ErrorInfo.
Does not implicitly attach the channel. It rejects with an ErrorInfo on a channel in the failed or suspended state, or when the connection is unusable.
The serial field of the message which has an annotation that you want to delete.
The annotation deletion request. It must include at least the type. Other required fields depend on the type.
A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.
await channel.annotations.delete(message.serial, { type: 'emoji:distinct.v1', name: '👍' });
https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-delete
Get all annotations for a given message.
Does not implicitly attach the channel, and can be called in any channel or connection state. It does not require the annotation_subscribe mode.
The supplied Message must carry a populated serial. A newly constructed Message has none, so the call rejects with an ErrorInfo.
Message annotations must be enabled for the channel's namespace by a rule. Without it the call rejects with an ErrorInfo.
The message to get annotations for.
Restrictions on which annotations to get, in particular a limit.
A promise which, upon success, will be fulfilled with a PaginatedResult object containing an array of Annotation objects. Upon failure, the promise will be rejected with an ErrorInfo object which explains the error.
const result = await channel.annotations.get(message, null);
https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-get
Get all annotations for a given message.
Does not implicitly attach the channel, and can be called in any channel or connection state. It does not require the annotation_subscribe mode.
The supplied serial must be a non-empty string, otherwise the call rejects with an ErrorInfo.
Message annotations must be enabled for the channel's namespace by a rule. Without it the call rejects with an ErrorInfo.
The serial of the message to get annotations for.
Restrictions on which annotations to get, in particular a limit.
A promise which, upon success, will be fulfilled with a PaginatedResult object containing an array of Annotation objects. Upon failure, the promise will be rejected with an ErrorInfo object which explains the error.
const result = await channel.annotations.get(message.serial, null);
https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-get
Publish a new annotation for a message. If the annotation specifies no action, it defaults to annotation.create.
The supplied Message must carry a populated serial. A newly constructed Message has none, so the call rejects with an ErrorInfo.
Message annotations must be enabled for the channel's namespace by a rule, and the key or token must have the annotation-publish capability. Without either the server rejects the operation, so the call rejects with an ErrorInfo.
Does not implicitly attach the channel. It rejects with an ErrorInfo on a channel in the failed or suspended state, or when the connection is unusable.
Annotation data is never encrypted, even when cipher is set, because the server must be able to read it to build summaries.
The message to annotate.
The annotation to publish. It must include at least the type. Other required fields depend on the annotation type.
A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.
await channel.annotations.publish(message, { type: 'emoji:distinct.v1', name: '👍' });
https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-publish
Publish a new annotation for a message. If the annotation specifies no action, it defaults to annotation.create.
The supplied serial must be a non-empty string, otherwise the call rejects with an ErrorInfo.
Message annotations must be enabled for the channel's namespace by a rule, and the key or token must have the annotation-publish capability. Without either the server rejects the operation, so the call rejects with an ErrorInfo.
Does not implicitly attach the channel. It rejects with an ErrorInfo on a channel in the failed or suspended state, or when the connection is unusable.
Annotation data is never encrypted, even when cipher is set, because the server must be able to read it to build summaries.
The serial field of the message to annotate.
The annotation to publish. It must include at least the type. Other required fields depend on the annotation type.
A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.
await channel.annotations.publish(message.serial, { type: 'emoji:distinct.v1', name: '👍' });
https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-publish
Registers a listener that is called each time an Annotation matching a given type is received on the channel. Implicitly attaches the channel unless attachOnSubscribe is false.
Individual annotations are delivered only to clients that request the annotation_subscribe mode via modes, since most clients can rely on the rolled-up summary updates instead. The server grants the mode only if the key or token has the annotation-subscribe capability, and silently drops it otherwise.
Message annotations must be enabled for the channel's namespace by a rule. Without it the attach rejects with an ErrorInfo.
On a channel in the failed state the call rejects before the listener is registered. If the channel attaches without the mode it also rejects, but the listener stays registered and will fire if the mode is granted later. Remove it with unsubscribe() if that is not what you want. When attachOnSubscribe is false and the channel is not yet attached, the call resolves and a listener that lacks the mode never fires.
A specific type string or an array of them to register the listener for.
Optional listener: messageCallback<Annotation>
An event listener function.
A promise which resolves upon success of the channel attach() operation and rejects with an ErrorInfo object upon its failure. When attachOnSubscribe is false, no attach is performed.
await channel.annotations.subscribe('emoji:distinct.v1', (annotation) => console.log(annotation.name));
https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-subscribe
Registers a listener that is called each time an Annotation is received on the channel. Implicitly attaches the channel unless attachOnSubscribe is false.
Individual annotations are delivered only to clients that request the annotation_subscribe mode via modes, since most clients can rely on the rolled-up summary updates instead. The server grants the mode only if the key or token has the annotation-subscribe capability, and silently drops it otherwise.
Message annotations must be enabled for the channel's namespace by a rule. Without it the attach rejects with an ErrorInfo.
On a channel in the failed state the call rejects before the listener is registered. If the channel attaches without the mode it also rejects, but the listener stays registered and will fire if the mode is granted later. Remove it with unsubscribe() if that is not what you want. When attachOnSubscribe is false and the channel is not yet attached, the call resolves and a listener that lacks the mode never fires.
Optional listener: messageCallback<Annotation>
An event listener function.
A promise which resolves upon success of the channel attach() operation and rejects with an ErrorInfo object upon its failure. When attachOnSubscribe is false, no attach is performed.
await channel.annotations.subscribe((annotation) => console.log(annotation.name));
https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-subscribe
Deregisters a specific listener that is registered to receive Annotation on the channel for a given type. This removes local listeners only and does not detach the channel. The server keeps streaming annotations to an attached channel, subject to the client's capabilities.
A specific annotation type (or array of types) to deregister the listener for.
An event listener function.
channel.annotations.unsubscribe('emoji:distinct.v1', listener);
https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-unsubscribe
Deregisters any listener that is registered to receive Annotation on the channel for a specific type. This removes local listeners only and does not detach the channel. The server keeps streaming annotations to an attached channel, subject to the client's capabilities.
A specific annotation type (or array of types) to deregister the listeners for.
Deregisters a specific listener that is registered to receive Annotation on the channel. This removes local listeners only and does not detach the channel. The server keeps streaming annotations to an attached channel, subject to the client's capabilities.
An event listener function.
Deregisters all listeners currently receiving Annotation for the channel. This removes local listeners only and does not detach the channel. The server keeps streaming annotations to an attached channel, subject to the client's capabilities.
Generated using TypeDoc
Functionality for annotating messages with small pieces of data, such as emoji reactions, that the server will roll up into the message as a summary.