ChatClientService
The ChatClient
service connects the user to the Stream chat.
Type parameters
Name | 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
projects/stream-chat-angular/src/lib/chat-client.service.ts:49
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
projects/stream-chat-angular/src/lib/chat-client.service.ts:38
connectionState$
connectionState$: Observable
<"offline"
| "online"
>
Emits the current connection state of the user (online
or offline
)
Defined in
projects/stream-chat-angular/src/lib/chat-client.service.ts:53
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
projects/stream-chat-angular/src/lib/chat-client.service.ts:45
pendingInvites$
pendingInvites$: Observable
<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
projects/stream-chat-angular/src/lib/chat-client.service.ts:57
user$
user$: Observable
<undefined
| OwnUserResponse
<T
> | UserResponse
<T
>>
Emits the current chat user
Defined in
projects/stream-chat-angular/src/lib/chat-client.service.ts:61
Methods
autocompleteUsers
autocompleteUsers(searchTerm
): Promise
<UserResponse
<T
>[]>
Searches for users in the application that have ID or name matching the provided search term
Parameters
Name | Type |
---|---|
searchTerm | string |
Returns
Promise
<UserResponse
<T
>[]>
The users matching the search
Defined in
projects/stream-chat-angular/src/lib/chat-client.service.ts:226
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
projects/stream-chat-angular/src/lib/chat-client.service.ts:188
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
Name | Type |
---|---|
messageId | string |
Returns
Promise
<void
>
Defined in
projects/stream-chat-angular/src/lib/chat-client.service.ts:217
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
projects/stream-chat-angular/src/lib/chat-client.service.ts:198
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
Name | Type | Description |
---|---|---|
apiKey | string | |
userOrId | undefined | string | OwnUserResponse <T > | UserResponse <T > | you can emit this for anonymous logins |
userTokenOrProvider | TokenOrProvider | You can provide:
|
clientOptions? | AxiosRequestConfig <any > & {} & { trackPendingChannelInvites? : boolean } | Setting to provide to the Stream client instance |
Returns
ConnectAPIResponse
<T
>
Defined in
projects/stream-chat-angular/src/lib/chat-client.service.ts:98