|
@@ -8,11 +8,13 @@ import { initSocket } from "./utils";
|
|
|
|
|
|
export type OnInitHandler = (appManager: TaipyApp) => void;
|
|
|
export type OnChangeHandler = (appManager: TaipyApp, encodedName: string, value: unknown) => void;
|
|
|
+export type OnNotifyHandler = (appManager: TaipyApp, type: string, message: string) => void;
|
|
|
|
|
|
export class TaipyApp {
|
|
|
socket: Socket;
|
|
|
_onInit: OnInitHandler | undefined;
|
|
|
_onChange: OnChangeHandler | undefined;
|
|
|
+ _onNotify: OnNotifyHandler | undefined;
|
|
|
variableData: DataManager | undefined;
|
|
|
functionData: DataManager | undefined;
|
|
|
appId: string;
|
|
@@ -60,6 +62,16 @@ export class TaipyApp {
|
|
|
this._onChange = handler;
|
|
|
}
|
|
|
|
|
|
+ get onNotify() {
|
|
|
+ return this._onNotify;
|
|
|
+ }
|
|
|
+ set onNotify(handler: OnNotifyHandler | undefined) {
|
|
|
+ if (handler !== undefined && handler?.length !== 3) {
|
|
|
+ throw new Error("onNotify() requires three parameters");
|
|
|
+ }
|
|
|
+ this._onNotify = handler;
|
|
|
+ }
|
|
|
+
|
|
|
// Utility methods
|
|
|
init() {
|
|
|
this.clientId = "";
|