@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.
@@ -24511,10 +24511,15 @@ func.api.watch = function (path, cb, opt = {}) {
24511
24511
  _session.watchers = {};
24512
24512
  }
24513
24513
 
24514
- _session.watchers[path] = cb;
24514
+ _session.watchers[path] = { ...opt, handler: cb };
24515
+
24515
24516
  if (opt.immediate) {
24516
24517
  const value = _.get(SESSION_OBJ[SESSION_ID].DS_GLB[0], path);
24517
24518
  cb({ path, newValue: value, oldValue: value, timestamp: Date.now(), opt });
24519
+
24520
+ if (opt.once) {
24521
+ delete _session.watchers[path];
24522
+ }
24518
24523
  }
24519
24524
  return 'ok';
24520
24525
  };
@@ -42757,15 +42762,19 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
42757
42762
 
42758
42763
  let watch_path = 'data_system.' + path;
42759
42764
 
42765
+ const runHandler = () => {
42766
+ const { handler, once } = _session?.watchers?.[watch_path];
42767
+ handler(change);
42768
+ if (once) {
42769
+ delete _session.watchers[watch_path];
42770
+ }
42771
+ };
42772
+
42760
42773
  if (_session?.watchers?.[watch_path]) {
42761
- const fx = _session?.watchers?.[watch_path];
42762
- fx(change);
42774
+ runHandler();
42763
42775
  } else {
42764
42776
  watch_path = 'data_system.SYS_GLOBAL_OBJ_REFS.' + path;
42765
- if (_session?.watchers?.[watch_path]) {
42766
- const fx = _session?.watchers?.[watch_path];
42767
- fx(change);
42768
- }
42777
+ runHandler();
42769
42778
  }
42770
42779
  if (_.isEqual(newValue, oldValue)) return;
42771
42780
  ////////////////////////