Skip to main content
Each component’s store lives in CometChatCore and owns fetching, paging, real-time SDK listeners and the Kit’s events. Both toolkits use the same store. Stores are @MainActor and @Observable.

Creating and Providing a Store

By default each component creates its own store. To configure it, create it yourself and pass it in.

State Observation

A store publishes its screen state as an enum. For Conversations:
UsersState, GroupsState and the others follow the same shape.
The store is @Observable, so a view that reads store.state updates with it:

Configuring Data Fetching

Pass a request builder to control what the component fetches.
A closure that returns a fresh builder — it is called for every fetch:
Pass the builder, not the result of .build(). The store builds the request itself, so it can rebuild it for a refresh.

List Operations

The Users and Groups stores offer these list operations:
The UIKit Conversations screen has mutators, which forward to its store:
ConversationsStore itself offers refresh(), loadMore(), delete(_:), scrollToTop() and sdkConversation(for:). The list never filters itself: search opens CometChatSearch.

Store Methods

A SwiftUI view is a value, so call methods on the store you passed in:

Changing a Store’s Behaviour

The list stores are public, not open: from your app you change their behaviour through their policy and properties rather than by subclassing — see Policies instead of overrides. The satellite stores CometChatThreadHeaderStore, CometChatFlagMessageStore and CometChatMessageInformationStore are open.

Seeded Stores for Previews and Tests

Every store has init(seeded:): it renders the state you give it and performs no fetching, so a preview or test needs no session.

Lifecycle Callbacks