ChatUserSearchController
ChatUserSearchController
is a controller class which allows observing a list of chat users based on the provided query.
public class ChatUserSearchController: DataController, DelegateCallable, DataStoreProvider
Inheritance
DataController
, DelegateCallable
, DataStoreProvider
Properties
client
The ChatClient
instance this controller belongs to.
public let client: ChatClient
users
The users matching the query of this controller.
public var users: LazyCachedMapCollection<ChatUser>
To observe changes of the users, set your class as a delegate of this controller or use the provided
Combine
publishers.
delegate
Set the delegate of UserListController
to observe the changes in the system.
public weak var delegate: ChatUserSearchControllerDelegate?
Methods
setDelegate(_:)
Sets the provided object as a delegate of this controller.
public func setDelegate<Delegate: ChatUserSearchControllerDelegate>(_ delegate: Delegate)
Parameters
delegate
: The object used as a delegate. It's referenced weakly, so you need to keep the object alive if you want keep receiving updates.
search(term:completion:)
Searches users for the given term.
public func search(term: String?, completion: ((_ error: Error?) -> Void)? = nil)
When this function is called, users
property of this controller will refresh with new users matching the term.
The delegate function didChangeUsers
will also be called.
Parameters
term
: Search term. If empty string ornil
, all users are fetched.completion
: Called when the controller has finished fetching remote data. If the data fetching fails, the error variable contains more details about the problem.
search(query:completion:)
Searches users for the given query.
public func search(query: UserListQuery, completion: ((_ error: Error?) -> Void)? = nil)
When this function is called, users
property of this controller will refresh with new users matching the term.
The delegate function didChangeUsers
will also be called.
Parameters
query
: Search query.completion
: Called when the controller has finished fetching remote data. If the data fetching fails, the error variable contains more details about the problem.
loadNextUsers(limit:completion:)
Loads next users from backend.
public func loadNextUsers(
limit: Int = 25,
completion: ((Error?) -> Void)? = nil
)
Parameters
limit
: Limit for page size.completion
: The completion. Will be called on acallbackQueue
when the network request is finished. If request fails, the completion will be called with an error.