ChatKitty
Search…
Users
These are your end-users.
A user represents an end-user using your application. Users can join channels, chat with other users, receive notifications and perform other actions. Users are identified by a unique name.

Properties

Name
Type
Description
Required
id
number
64-bit integer identifier associated with this user
name
string
The unique name of the user
displayName
string
Human readable name of this user. Shown to other users
displayPictureUrl
string
URI for this user's display picture
isGuest
boolean
True if this user was created by a guest user session
-
properties
object
Custom data associated with this user

Current User

After starting a ChatKitty user session, you can request the current user anytime.
1
const result = await kitty.getCurrentUser();
2
3
const user = result.user; // Handle user
Copied!

Observing the current user

Get updates when the current user changes by registering an observer function.
1
const unsubscribe = kitty.onCurrentUserChanged((user) => {
2
// handle new current user or current user changes
3
});
4
5
// call when you're no longer interested in updates
6
unsubscribe();
Copied!
The observer function passed to onCurrentUserChanged is called with the current user value when first registered.

Updating the current user

Update the current user by passing a function taking the current user and returning a user with the changes to be applied to your ChatKitty client instance.
1
await kitty.updateCurrentUser((user) => {
2
// Perform updates
3
user.properties = {
4
...user.properties,
5
'favorite-number': 42,
6
};
7
8
return user; // Return updated user
9
});
Copied!

See also

See also

Last modified 3mo ago