returns the reactive state object of Chat
// returns the current state of Chat
const state = $$("ch").getState();
The returned state object contains the following properties and methods:
callUsers: [9, 3],
- userId (number, string) - the id of the user with whom a private chat is active now
- search (string) - the value in the search field above the list of chats/users
- chatType (string) - the type of the current chat ("chat" or "user"). "chat" stands for a group chat, "user" is a private chat
- callStatus (number) - status of the call. Can have the following values:
- 1 - CallStatusInitiated
- 2 - CallStatusAccepted
- 3 - CallStatusActive
- 900 - CallStatusDrop
- 901 - CallStatusRejected
- 902 - CallStatusEnded
- 903 - CallStatusIgnored
- 904 - CallStatusLost.
- callId (number) - stores the call ID
- callUsers (array) - an array with IDs of users participating in the call
- callChatId (number) - ID of the chat the call is in
- timer (number) - call timer. Increments the time field
- time (number) - number of second passed from the beginning of the call.
Back to top
- $observe (function) - a handler to listen to changes in the current state of Chat. It takes 2 parameters:
- prop (string) - a reactive property to listen changes of
- handler (function) - a function to execute when changes are made. It takes the only argument:
- value (any) - the current value of the reactive property. The type of the value (string, array, etc) depends on a reactive property being observed.
- batch (function)- allows to set several properties at once. Takes the only parameter:
- props (object) - an object containing the pairs of the property name and the value to set.