As Chat is an application based on Webix Jet it consists of many stand-alone Webix components. You can customize its inner views or work with Chat-specific confgiuration.
You can use the following settings to provide the basic config of the widget:
Note that token is an optional property used by the built-in Backend service to pass it to the server. You can specify your own way of the user authentication.
In addition to the basic setting, Chat has specific reactive properties that store global app state and let developers track its changes:
You can get the current state of the widget with the help of the getState() method:
webix.ui({
view:"chat",
id:"myChat",
token, // token got from the server
url: "https://docs.webix.com/chat-backend/"
});
var state = $$("myChat").getState();
/*
{
chatId: 6,
chatType: "chat",
search: "",
userId: null
}
*/
The state object also contains several read-only properties:
You can use $observe handler to listen to changes and provide custom handlers for them:
webix.ui({
view: "chat",
url: "https://docs.webix.com/chat-backend/",
on: {
onInit: app => {
const state = app.getState();
state.$observe("chatId", id => {
webix.message("The chat id is " + id);
});
}
}
});
Related sample: Chat: Listening to States
In the sample above, the current state is accessed via the instance of the inner JetApp which is available in the onInit event handler.
Back to top