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
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.
const result = await kitty.getCurrentUser();
const user = result.user; // Handle user
Observing the current user
Get updates when the current user changes by registering an observer function.
const unsubscribe = kitty.onCurrentUserChanged((user) => {
// handle new current user or current user changes
});
// call when you're no longer interested in updates
unsubscribe();
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.
await kitty.updateCurrentUser((user) => {
// Perform updates
user.properties = {
...user.properties,
'favorite-number': 42,
};
return user; // Return updated user
});
See also
See also
Last updated