Skip to main content

ChatClientService#

The ChatClient service connects the user to the Stream chat.

Type parameters#

NameType
Textends DefaultStreamChatGenerics = DefaultStreamChatGenerics

Properties#

appSettings$#

appSettings$: Observable<undefined | AppSettings>

Emits the current application settings. Since getting the application settings is an expensive API call and we don't always need the result, this is not initialized by default, you need to call getApplicationSettings to load them.

Defined in#

lib/chat-client.service.ts:48


chatClient#

chatClient: StreamChat<T>

The StreamChat client instance. In general you shouldn't need to access the client, but it's there if you want to use it.

Defined in#

lib/chat-client.service.ts:37


connectionState$#

connectionState$: Observable<"offline" | "online">

Emits the current connection state of the user (online or offline)

Defined in#

lib/chat-client.service.ts:52


events$#

events$: Observable<ClientEvent<T>>

Emits ClientEvent events. The platform documentation covers the list of client, user presence and notification events.

important

For performance reasons this Observable operates outside of the Angular change detection zone. If you subscribe to it, you need to manually reenter Angular's change detection zone, our Change detection guide explains this in detail.

Defined in#

lib/chat-client.service.ts:44


pendingInvites$#

pendingInvites$: Observable<(ChannelResponse<T> | Channel<T>)[]>

Emits the list of pending invites of the user. It emits every pending invitation during initialization and then extends the list when a new invite is received. More information can be found in the channel invitations guide.

Defined in#

lib/chat-client.service.ts:56


user$#

user$: Observable<undefined | UserResponse<T>>

Emits the current chat user

Defined in#

lib/chat-client.service.ts:60

Methods#

autocompleteUsers#

autocompleteUsers(searchTerm): Promise<UserResponse<T>[]>

Searches for users in the application that have ID or name matching the provided search term

Parameters#

NameType
searchTermstring

Returns#

Promise<UserResponse<T>[]>

The users matching the search

Defined in#

lib/chat-client.service.ts:193


disconnectUser#

disconnectUser(): Promise<void>

Disconnects the current user, and closes the WebSocket connection. Useful when disconnecting a chat user, use in combination with reset.

Returns#

Promise<void>

Defined in#

lib/chat-client.service.ts:162


flagMessage#

flagMessage(messageId): Promise<void>

Flag the message with the given ID. If you want to know more about flags check out the platform documentation.

Parameters#

NameType
messageIdstring

Returns#

Promise<void>

Defined in#

lib/chat-client.service.ts:184


getAppSettings#

getAppSettings(): Promise<void>

Loads the current application settings, if the application settings have already been loaded, it does nothing.

Returns#

Promise<void>

Defined in#

lib/chat-client.service.ts:172


init#

init(apiKey, userOrId, userTokenOrProvider, clientOptions?): ConnectAPIResponse<T>

Creates a StreamChat instance using the provided apiKey, and connects a user with the given meta data and token. More info about connecting users can be found in the platform documentation.

Parameters#

NameTypeDescription
apiKeystring
userOrIdstring | UserResponse<T> | OwnUserResponse<T>
userTokenOrProviderTokenOrProviderYou can provide a token, or the keyword 'guest' to connect as guest user
clientOptions?StreamChatOptionsSetting to provide to the Stream client instance

Returns#

ConnectAPIResponse<T>

Defined in#

lib/chat-client.service.ts:90

Did you find this page helpful?