Skip to main content

Handle synchronization events

The channel.object instance emits synchronization events that indicate when the local state on the client is being synchronized with the Ably service. These events can be useful for displaying loading indicators, preventing user interactions during synchronization, or triggering application logic when data is first loaded.

Handle object lifecycle events

Detect object deletion

Objects can become unreachable when they are removed from the object tree using remove() and never reassigned. Unreachable objects are garbage collected by Ably, typically after 24 hours. Since deleted objects are unreachable via any path, object.delete events can only be received through Instance subscriptions, which track a specific object by its ID regardless of its location in the object tree:
In most cases, you don’t need to explicitly handle object deletion. Your application should have already reacted to object removal when a corresponding LiveMap.remove() operation was received. However, if your application separately stores references to object instances and does not properly clear them when objects are orphaned, any later interactions with those objects after they are deleted will result in an error. In such cases, handling deletion events via Instance subscriptions helps ensure that those references are cleaned up and runtime errors are avoided.