Webix-JET websocket example


I have a Jet app using your websocket example:

webix.proxy.socket = {
    load:function(view) {
        //create a socket connection
        this.socket = new WebSocket("ws:"+this.source);

        //handle errors
        this.socket.onerror = (error) => {
            console.log("WebSocket Error", error);
        //receive updates
        this.socket.onmessage = (e) => {
            // update view data
            // ...
        //close a socket connection when a view is destroyed
        view.attachEvent("onDestruct", () => {
    save:function(view, update) {
        //send message to server

problem is when I save I get this.socket is undefined.
Any help would be greatly appreciated.



We’ve tested the issue, and, it seems, there’s a bug in Webix Jet. When Jet copies the config, it removes some properties from the objects.

As a workaround, you can save on the view instead of proxy (this): Code Snippet

[Updated]: After studying the issue, we’ve came to the conclusion that it was caused by CopyConfig:


here both url and save reference the same object, after CopyConfig, each property will reference its own UNIQUE config object, so when Socket is created in the load handler, it will affect “url” but will not affect “save” as they are different objects now.

The best alternative for it will be to move data load/save logic into the “init” handler:

var data_proxy = webix.proxy("socket", "[//localhost:8080](https://localhost:8080/)", {
key:"data", clientId:webix.uid()

const grid = this.$$("grid");
webix.dp({ master: grid, url: data_proxy })