TypeScript Live Objects/Collections
In the Social Plus TypeScript SDK, we have the concept of Live Object and Live Collection.
Live Object is represented by an instance of Social Plus Object. It helps to observe changes in a single object.
Live Collection is represented by an instance of Social Plus LiveCollection. It helps to observe changes in a list of objects.
For example: Amity.Post
or Amity.LiveCollection<Amity.Post>
SDK handles lots of data received from various sources. Data can be present in the local cache. It may also be queried from the server or received from real-time events. What this means is that the same data is constantly updating. The data that you are accessing at the moment can get updated and become out of sync.
Live Object and Live Collection help in syncing data so you will always get the most recent one. New data gets automatically collected every time when there is an update and the user need not refresh to get the recent data.
Live Collection is available for the following in user/community feeds:
Post Collection
Comment Collection
Reactions Collection
Followers/Following Collection
Channel Collection
Sub Channel Collection
Message Collection
Channel Member Collection
Community Collection
Community Category Collection
Community Objects
Community Members Collection
File Collection
Story Collection
Stream Collection
User Collection
Live Collection is not supported for global feed and custom post ranking.
Live Object
Although live objects were introduced prior to v6. All getter methods for singular objects (example getPost
) will now return a subscribe-able object.
This means that if an object gets updated and you have subscribed to real-time events, the object will get updated automatically via real-time events.
If for your use case, you don't require any real-time updates, you can unsubscribe immediately. For further information about Live Object, please visit Live Object page.
Getting Real Time Updates for an Object
Getting the object only once
Live Collection
Although live collections were introduced prior to v6. All query methods for the collection of objects (example getPosts
) will now return a subscribe-able collection.
This means that if an object in the collection gets updated and you have subscribed to real-time events, the collection will get updated automatically via real-time events.
If for your use case, you don't require any real-time updates, you can unsubscribe immediately. Similar to the live objects above. For further information about Live Collection, please visit Live Collection page.
Getting Real-Time updates for a collection
Getting paginated collection without and real-time updates
Last updated