getState

returns the reactive state object of Chat

object getState();
objectstate object

Example

// returns the current state of Chat
const state = $$("ch").getState();

Related samples

Details

The returned state object contains the following properties and methods:

{
  chatId: 6,
  chatType: "chat",
  search: "",
  userId: 9,
  callStatus: 1,
  callId: 4,
  callUsers: [9, 3],
  callChatId: 6,
  timer: 5000,
  time: 5
}

Properties

  • 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.

Methods

  • $observe (function) - a handler to listen to changes in the current state of Chat. It takes 2 parameters:
    • prop (string) - a reactive property whose changes you want to listen to;
    • handler (function) - a function to execute when changes are made. It takes a single argument:
      • value (any) - the current value of the reactive property. The type of the value (string, array, etc.) depends on the reactive property being observed.
  • $batch (function) - allows setting several properties at once. It takes a single parameter:
    • props (object) - an object containing pairs of property names and values to set.
Back to top
Join Our Forum
We've retired comments here. Visit our forum for faster technical support, connect with other developers, and share your feedback there.