@xuda.io/runtime-bundle 1.0.1357 → 1.0.1358

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.
@@ -24502,7 +24502,7 @@ func.api.call_javascript = async function (prog_id, params, evaluate) {
24502
24502
  return await api_utils.call_javascript(prog_id, params, evaluate);
24503
24503
  };
24504
24504
 
24505
- func.api.watch = function (path, cb) {
24505
+ func.api.watch = function (path, cb, opt = {}) {
24506
24506
  if (!path) return 'path is mandatory';
24507
24507
  if (!cb) return 'cb (callback function) is mandatory';
24508
24508
  const SESSION_ID = Object.keys(SESSION_OBJ)[0];
@@ -24512,7 +24512,10 @@ func.api.watch = function (path, cb) {
24512
24512
  }
24513
24513
 
24514
24514
  _session.watchers[path] = cb;
24515
-
24515
+ if (opt.immediate) {
24516
+ const value = _.get(SESSION_OBJ[SESSION_ID][0], path);
24517
+ cb({ path, newValue: value, oldValue: value, timestamp: Date.now(), opt });
24518
+ }
24516
24519
  return 'ok';
24517
24520
  };
24518
24521