@xuda.io/runtime-bundle 1.0.1327 → 1.0.1328

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2500,6 +2500,20 @@ func.api.call_javascript = async function (prog_id, params, evaluate) {
2500
2500
  return await api_utils.call_javascript(prog_id, params, evaluate);
2501
2501
  };
2502
2502
 
2503
+ func.api.watch = async function (path, cb) {
2504
+ if (!path) return 'path is mandatory';
2505
+ if (!cb) return 'cb (callback function) is mandatory';
2506
+ const SESSION_ID = Object.keys(SESSION_OBJ)[0];
2507
+ let _session = SESSION_OBJ[SESSION_ID];
2508
+ if (!_session.watchers) {
2509
+ _session.watchers = {};
2510
+ }
2511
+
2512
+ _session.watchers[path] = cb;
2513
+
2514
+ return 'ok';
2515
+ };
2516
+
2503
2517
  // func.api.call_javascript = async function (prog_id, params, evaluate) {
2504
2518
  // const SESSION_ID = Object.keys(SESSION_OBJ)[0];
2505
2519
  // const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
@@ -20104,6 +20118,13 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
20104
20118
  try {
20105
20119
  if (_.isEqual(newValue, oldValue)) return;
20106
20120
 
20121
+ const _session = SESSION_OBJ[SESSION_ID];
20122
+
20123
+ if (_session?.watchers?.[path]) {
20124
+ const fx = _session?.watchers?.[path];
20125
+ fx(change);
20126
+ }
20127
+
20107
20128
  if (!change.path.includes('data_system.SYS_GLOBAL_OBJ_REFS')) return;
20108
20129
  const ref_id = change.path.split('SYS_GLOBAL_OBJ_REFS.')[1].split('.')[0];
20109
20130
  if (!ref_id) return;
@@ -2501,6 +2501,20 @@ func.api.call_javascript = async function (prog_id, params, evaluate) {
2501
2501
  return await api_utils.call_javascript(prog_id, params, evaluate);
2502
2502
  };
2503
2503
 
2504
+ func.api.watch = async function (path, cb) {
2505
+ if (!path) return 'path is mandatory';
2506
+ if (!cb) return 'cb (callback function) is mandatory';
2507
+ const SESSION_ID = Object.keys(SESSION_OBJ)[0];
2508
+ let _session = SESSION_OBJ[SESSION_ID];
2509
+ if (!_session.watchers) {
2510
+ _session.watchers = {};
2511
+ }
2512
+
2513
+ _session.watchers[path] = cb;
2514
+
2515
+ return 'ok';
2516
+ };
2517
+
2504
2518
  // func.api.call_javascript = async function (prog_id, params, evaluate) {
2505
2519
  // const SESSION_ID = Object.keys(SESSION_OBJ)[0];
2506
2520
  // const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
@@ -20105,6 +20119,13 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
20105
20119
  try {
20106
20120
  if (_.isEqual(newValue, oldValue)) return;
20107
20121
 
20122
+ const _session = SESSION_OBJ[SESSION_ID];
20123
+
20124
+ if (_session?.watchers?.[path]) {
20125
+ const fx = _session?.watchers?.[path];
20126
+ fx(change);
20127
+ }
20128
+
20108
20129
  if (!change.path.includes('data_system.SYS_GLOBAL_OBJ_REFS')) return;
20109
20130
  const ref_id = change.path.split('SYS_GLOBAL_OBJ_REFS.')[1].split('.')[0];
20110
20131
  if (!ref_id) return;