@xuda.io/runtime-bundle 1.0.1359 → 1.0.1361

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.
@@ -2509,10 +2509,15 @@ func.api.watch = function (path, cb, opt = {}) {
2509
2509
  _session.watchers = {};
2510
2510
  }
2511
2511
 
2512
- _session.watchers[path] = cb;
2512
+ _session.watchers[path] = { ...opt, handler: cb };
2513
+
2513
2514
  if (opt.immediate) {
2514
2515
  const value = _.get(SESSION_OBJ[SESSION_ID].DS_GLB[0], path);
2515
2516
  cb({ path, newValue: value, oldValue: value, timestamp: Date.now(), opt });
2517
+
2518
+ if (opt.once) {
2519
+ delete _session.watchers[path];
2520
+ }
2516
2521
  }
2517
2522
  return 'ok';
2518
2523
  };
@@ -20270,15 +20275,19 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
20270
20275
 
20271
20276
  let watch_path = 'data_system.' + path;
20272
20277
 
20278
+ const runHandler = () => {
20279
+ const { handler, once } = _session?.watchers?.[watch_path];
20280
+ handler(change);
20281
+ if (once) {
20282
+ delete _session.watchers[watch_path];
20283
+ }
20284
+ };
20285
+
20273
20286
  if (_session?.watchers?.[watch_path]) {
20274
- const fx = _session?.watchers?.[watch_path];
20275
- fx(change);
20287
+ runHandler();
20276
20288
  } else {
20277
20289
  watch_path = 'data_system.SYS_GLOBAL_OBJ_REFS.' + path;
20278
- if (_session?.watchers?.[watch_path]) {
20279
- const fx = _session?.watchers?.[watch_path];
20280
- fx(change);
20281
- }
20290
+ runHandler();
20282
20291
  }
20283
20292
  if (_.isEqual(newValue, oldValue)) return;
20284
20293
  ////////////////////////
@@ -2510,10 +2510,15 @@ func.api.watch = function (path, cb, opt = {}) {
2510
2510
  _session.watchers = {};
2511
2511
  }
2512
2512
 
2513
- _session.watchers[path] = cb;
2513
+ _session.watchers[path] = { ...opt, handler: cb };
2514
+
2514
2515
  if (opt.immediate) {
2515
2516
  const value = _.get(SESSION_OBJ[SESSION_ID].DS_GLB[0], path);
2516
2517
  cb({ path, newValue: value, oldValue: value, timestamp: Date.now(), opt });
2518
+
2519
+ if (opt.once) {
2520
+ delete _session.watchers[path];
2521
+ }
2517
2522
  }
2518
2523
  return 'ok';
2519
2524
  };
@@ -20271,15 +20276,19 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
20271
20276
 
20272
20277
  let watch_path = 'data_system.' + path;
20273
20278
 
20279
+ const runHandler = () => {
20280
+ const { handler, once } = _session?.watchers?.[watch_path];
20281
+ handler(change);
20282
+ if (once) {
20283
+ delete _session.watchers[watch_path];
20284
+ }
20285
+ };
20286
+
20274
20287
  if (_session?.watchers?.[watch_path]) {
20275
- const fx = _session?.watchers?.[watch_path];
20276
- fx(change);
20288
+ runHandler();
20277
20289
  } else {
20278
20290
  watch_path = 'data_system.SYS_GLOBAL_OBJ_REFS.' + path;
20279
- if (_session?.watchers?.[watch_path]) {
20280
- const fx = _session?.watchers?.[watch_path];
20281
- fx(change);
20282
- }
20291
+ runHandler();
20283
20292
  }
20284
20293
  if (_.isEqual(newValue, oldValue)) return;
20285
20294
  ////////////////////////