ThreadListController

class ThreadListController(query: QueryThreadsRequest, chatClient: ChatClient = ChatClient.instance(), scope: CoroutineScope = CoroutineScope(DispatcherProvider.IO.limitedParallelism(1)), queryThreadsAsState: (CoroutineScope) -> StateFlow<QueryThreadsState?> = { stateScope -> chatClient.queryThreadsAsState( request = query, coroutineScope = stateScope, ) }) : AutoCloseable

Controller responsible for managing the Threads list state. It serves as a central place for the state management and business logic related to the Threads list.

Parameters

query

The QueryThreadsRequest object containing the parameters for querying threads.

chatClient

The ChatClient instance for retrieving the Threads related data.

scope

The CoroutineScope the controller's work runs under, in a child scope that close cancels; the given scope itself is never cancelled. The default one outlives user sessions, so the list can follow the next user, and runs one task at a time.

queryThreadsAsState

Function that returns a StateFlow of QueryThreadsState, built in the given scope.

Constructors

Link copied to clipboard
constructor(query: QueryThreadsRequest, chatClient: ChatClient = ChatClient.instance(), scope: CoroutineScope = CoroutineScope(DispatcherProvider.IO.limitedParallelism(1)), queryThreadsAsState: (CoroutineScope) -> StateFlow<QueryThreadsState?> = { stateScope -> chatClient.queryThreadsAsState( request = query, coroutineScope = stateScope, ) })

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The state of our network connection - if we're online, connecting or offline.

Link copied to clipboard
val state: StateFlow<ThreadListState>
Link copied to clipboard
val user: StateFlow<User?>

The state of the currently logged in user.

Functions

Link copied to clipboard
open override fun close()

Cancels the work started by this controller, without cancelling the scope it was given.

Link copied to clipboard
fun load()

Force loads the first page of threads.

Link copied to clipboard

Loads the next page of threads (if possible).