#
ChatClientServiceThe ChatClient
service connects the user to the Stream chat.
#
Type parametersName | Type |
---|---|
T | extends 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#
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#
connectionState$• connectionState$: Observable
<"offline"
| "online"
>
Emits the current connection state of the user (online
or offline
)
#
Defined in#
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#
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#
user$• user$: Observable
<undefined
| UserResponse
<T
>>
Emits the current chat user
#
Defined in#
Methods#
autocompleteUsers▸ autocompleteUsers(searchTerm
): Promise
<UserResponse
<T
>[]>
Searches for users in the application that have ID or name matching the provided search term
#
ParametersName | Type |
---|---|
searchTerm | string |
#
ReturnsPromise
<UserResponse
<T
>[]>
The users matching the search
#
Defined inlib/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
.
#
ReturnsPromise
<void
>
#
Defined inlib/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.
#
ParametersName | Type |
---|---|
messageId | string |
#
ReturnsPromise
<void
>
#
Defined inlib/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.
#
ReturnsPromise
<void
>
#
Defined inlib/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.
#
ParametersName | Type | Description |
---|---|---|
apiKey | string | |
userOrId | string | UserResponse <T > | OwnUserResponse <T > | |
userTokenOrProvider | TokenOrProvider | You can provide a token, or the keyword 'guest' to connect as guest user |
clientOptions? | StreamChatOptions | Setting to provide to the Stream client instance |
#
ReturnsConnectAPIResponse
<T
>