@xuda.io/xuda-worker-bundle 1.3.2492 → 1.3.2493
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.
- package/index.js +5 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -876,7 +876,7 @@ func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
|
876
876
|
return await api_utils.call_javascript(prog_id, params, evaluate);
|
|
877
877
|
};
|
|
878
878
|
|
|
879
|
-
func.api.watch = function (path, cb) {
|
|
879
|
+
func.api.watch = function (path, cb, opt = {}) {
|
|
880
880
|
if (!path) return 'path is mandatory';
|
|
881
881
|
if (!cb) return 'cb (callback function) is mandatory';
|
|
882
882
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
@@ -886,7 +886,10 @@ func.api.watch = function (path, cb) {
|
|
|
886
886
|
}
|
|
887
887
|
|
|
888
888
|
_session.watchers[path] = cb;
|
|
889
|
-
|
|
889
|
+
if (opt.immediate) {
|
|
890
|
+
const value = _.get(SESSION_OBJ[SESSION_ID][0], path);
|
|
891
|
+
cb({ path, newValue: value, oldValue: value, timestamp: Date.now(), opt });
|
|
892
|
+
}
|
|
890
893
|
return 'ok';
|
|
891
894
|
};
|
|
892
895
|
|