Repository: Avaiga/taipy
File: frontend/taipy-gui/base/src/app.ts (TypeScript)

Code before:
            throw new Error("onNotify() requires three parameters");
        }
        this._onNotify = handler;
    }

    get onReload() {
        return this._onReload;
    }
    set onReload(handler: OnReloadHandler | undefined) {
        if (handler !== undefined && handler?.length !== 2) {
            throw new Error("_onReload() requires two parameters");
        }
        this._onReload = handler;
    }

    // Utility methods
    init() {
        this.clientId = "";
        this.context = "";
        this.appId = "";
        this.routes = undefined;
        const id = getLocalStorageValue(TAIPY_CLIENT_ID, "");
        sendWsMessage(this.socket, "ID", TAIPY_CLIENT_ID, id, id, undefined, false);
        sendWsMessage(this.socket, "AID", "connect", "", id, undefined, false);
        sendWsMessage(this.socket, "GR", "", "", id, undefined, false);
        if (id !== "") {
            this.clientId = id;
            this.updateContext(this.path);
        }
    }

    // Public methods
    registerWsAdapter(wsAdapter: WsAdapter) {
        this.wsAdapters.unshift(wsAdapter);
    }

    getEncodedName(varName: string, module: string) {
        return this.variableData?.getEncodedName(varName, module);
    }

    getName(encodedName: string) {
        return this.variableData?.getName(encodedName);
    }

    get(encodedName: string) {
        return this.variableData?.get(encodedName);
    }

    getInfo(encodedName: string) {
        return this.variableData?.getInfo(encodedName);
    }

Review comment (suggestion):
```suggestion
            throw new Error("onWsStatusUpdate() requires two parameters");
```

Code after:
        return this._onNotify;
    }

    set onNotify(handler: OnNotifyHandler | undefined) {
        if (handler !== undefined && handler.length !== 3) {
            throw new Error("onNotify() requires three parameters");
        }
        this._onNotify = handler;
    }

    get onReload() {
        return this._onReload;
    }
    set onReload(handler: OnReloadHandler | undefined) {
        if (handler !== undefined && handler?.length !== 2) {
            throw new Error("_onReload() requires two parameters");
        }
        this._onReload = handler;
    }

    get onWsStatusUpdate() {
        return this._onWsStatusUpdate;
    }
    set onWsStatusUpdate(handler: OnWsStatusUpdate | undefined) {
        if (handler !== undefined && handler?.length !== 2) {
            throw new Error("_onWsStatusUpdate() requires two parameters");
        }
        this._onWsStatusUpdate = handler;
    }

    // Utility methods
    init() {
        this.clientId = "";
        this.context = "";
        this.appId = "";
        this.routes = undefined;
        const id = getLocalStorageValue(TAIPY_CLIENT_ID, "");
        this.sendWsMessage("ID", TAIPY_CLIENT_ID, id);
        this.sendWsMessage("AID", "connect", "");
        this.sendWsMessage("GR", "", "");
        if (id !== "") {
            this.clientId = id;
            this.updateContext(this.path);
        }
    }

    sendWsMessage(type: WsMessageType, id: string, payload: unknown, context: string | undefined = undefined) {
        if (context === undefined) {
            context = this.context;
        }
        const ackId = sendWsMessage(this.socket, type, id, payload, this.clientId, context);