- When data get updated by an action from the current device
- Real-time events of the subscribed data from the server
Refer to the platform-specific subpages in this section for an in-depth explanation of how your SDK handles live objects and live collections.
Data Sources
Local Actions
Updates from user interactions within your current device
Real-time Events
Live changes from subscribed objects on the server
Live Object
Live Object allows users to observe the states of a single object within the app, such as a post, message, or channel. With Live Object, users can automatically receive notifications of any data updates related to the observed object, whether from the network or locally.Key Features
Observer Design Pattern
Observer Design Pattern
Live Object API is designed around the observer design pattern, allowing users to subscribe to an object, receive notifications of any data updates, and unsubscribe when necessary.
Additional States
Additional States
Live Object also provides additional states, such as
isLoading
and error
, which can help understand the status of the observed object and any potential issues that may arise.Snapshot Delivery
Snapshot Delivery
These updates are delivered via Snapshot, a captured state that is frozen and cannot be changed. Users can own and access these snapshots to stay up-to-date with the latest data within the app.
Immutable Snapshots
Immutable Snapshots
It’s worth noting that while data updates may occur internally within the SDK, these updates will not affect previous snapshots. The only way for users to see the latest data is by getting new snapshots delivered via Live Object updates.
Use Cases
Live Object is ideal for monitoring individual entities such as:- Posts: Track likes, comments, and content updates
- Messages: Monitor delivery status, read receipts, and reactions
- Channels: Observe member count changes and channel metadata
- User Profiles: Watch status updates, avatar changes, and online presence
Live Object Architecture
Live Collection
Live Collection allows users to observe changes to an entire collection of data within their app in real-time. Live Collection works similarly to Live Object, with the main difference being that Live Collection notifies changes related to the entire collection rather than just a single object.How It Works
To use Live Collection, users can observe changes in a specific collection within the SDK. The collection handler then receives a snapshot of changes since the last result, which includes three possible events:Deletions
The indices of the objects that were deleted
Insertions
The indices of the objects that were inserted
Modifications
The indices of the objects that were modified
Change Detection
Live Collections provide granular change notifications instead of replacing entire datasets:Change Type | Description | Benefit |
---|---|---|
Insertions | New items added to collection | Efficient UI updates for new content |
Deletions | Items removed from collection | Smooth removal animations |
Modifications | Existing items updated | Targeted updates without full refresh |
Use Cases
By subscribing to changes on a specific collection using Live Collection, users can stay up-to-date with the latest changes and updates to important collections within the app. This can be particularly helpful for:- Managing large amounts of data: Efficiently handle extensive datasets without performance impact
- Monitoring frequently updated collections: Track changes to dynamic content like messages or posts
- Real-time social feeds: Display new posts, comments, and reactions as they happen
- Chat message lists: Show new messages instantly with typing indicators
- Member lists: Track community or channel membership changes
Live Collection Architecture
\Best Practices
Memory Management
Memory Management
Proper Cleanup: Always unsubscribe from observers to prevent memory leaks when components unmount or views disappear.
Performance Optimization
Performance Optimization
Efficient Updates: Use collection change indices for targeted UI updates instead of full re-renders. Only update the specific items that changed.
Error Handling
Error Handling
Graceful Degradation: Handle network errors and loading states appropriately using the built-in
isLoading
and error
states.Real-time Subscriptions
Real-time Subscriptions
Topic Management: Subscribe to relevant real-time topics for automatic updates. Ensure proper cleanup when no longer needed.
Platform Implementation
Each platform has its own specific implementation patterns for Live Objects and Collections:iOS Implementation
Learn iOS-specific patterns for observers and delegates
Android Implementation
Discover Android LiveData and RxJava integration
Flutter Implementation
Understand Dart streams and reactive widgets
Related Concepts
Real-time Events
Learn how Live Objects connect to real-time updates
Realtime Events Overview
Explore event channels powering live updates
Development Tip: Use platform-specific debugging tools to monitor subscription status and data flow in your Live Objects and Collections during development.