returns the reactive state object of Chat
void getState(object state);
// returns the current state of Chat
const state = $$("ch").getState();
The returned state object contains the following properties and methods:
- chatId (number) - the id of the chat being viewed currently;
- userId (number) - the id of the selected user in "users" list / user id in the selected private chat;
- search (string) - the search value of the active list ( "Chats" or "Users");
- chatType (string) - the type of the current chat ("chat" or "user"). "chat" is a group chat, "user" is a personal chat.
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.