@azrico/webobject 1.4.146 → 1.4.147
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.
|
@@ -52,14 +52,14 @@ export declare class SimpleObject extends MapableObject {
|
|
|
52
52
|
* @param value
|
|
53
53
|
* @return true if changed , false otherwise
|
|
54
54
|
*/
|
|
55
|
-
setValue(key: WriteablePropOf<this>, value: any,
|
|
55
|
+
setValue(key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType): Promise<boolean>;
|
|
56
56
|
/**
|
|
57
57
|
* set value
|
|
58
58
|
* @param key
|
|
59
59
|
* @param value
|
|
60
60
|
* @return true if changed , false otherwise
|
|
61
61
|
*/
|
|
62
|
-
set: (key: WriteablePropOf<this>, value: any,
|
|
62
|
+
set: (key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType) => Promise<boolean>;
|
|
63
63
|
setTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
64
64
|
clearRefreshFunction(): Promise<void>;
|
|
65
65
|
setRefreshFunction(new_fnc: any): Promise<any>;
|
|
@@ -120,7 +120,15 @@ export declare class SimpleObject extends MapableObject {
|
|
|
120
120
|
* @returns
|
|
121
121
|
*/
|
|
122
122
|
pushValues<MKey extends PropOf<this>>(key: MKey, values: any[], sendChanges?: sendChangesType): Promise<this[MKey] | false>;
|
|
123
|
-
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
* @param type
|
|
126
|
+
* @param key
|
|
127
|
+
* @param value
|
|
128
|
+
* @param subvalue
|
|
129
|
+
* @returns true if manager was notified. false otherwise
|
|
130
|
+
*/
|
|
131
|
+
notifyChanged<MKey extends PropOf<this>>(type: string, key: MKey | string, value: any, subvalue?: any): Promise<false | any[] | undefined>;
|
|
124
132
|
/**
|
|
125
133
|
* check if a key can be changed on an object
|
|
126
134
|
* @param object the object we are checking
|
|
@@ -147,13 +155,13 @@ export declare class SimpleObject extends MapableObject {
|
|
|
147
155
|
* set the value to its original
|
|
148
156
|
* @param key
|
|
149
157
|
*/
|
|
150
|
-
reset(key: WriteablePropOf<this>,
|
|
158
|
+
reset(key: WriteablePropOf<this>, shouldNotify?: sendChangesType): Promise<boolean>;
|
|
151
159
|
/**
|
|
152
160
|
* reset all values back to their original
|
|
153
161
|
* difference between this and clear_changes is that this function also calls on_change
|
|
154
162
|
* @param key
|
|
155
163
|
*/
|
|
156
|
-
resetAll(
|
|
164
|
+
resetAll(shouldNotify?: sendChangesType): Promise<boolean>;
|
|
157
165
|
/**
|
|
158
166
|
* clear and discard all changes
|
|
159
167
|
* does not call any on_change functions
|
|
@@ -146,14 +146,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
146
146
|
*/
|
|
147
147
|
function () {
|
|
148
148
|
var _setValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
|
|
149
|
-
var
|
|
149
|
+
var shouldNotify,
|
|
150
150
|
isValueChanged,
|
|
151
151
|
oldval,
|
|
152
152
|
_args = arguments;
|
|
153
153
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
154
154
|
while (1) switch (_context.prev = _context.next) {
|
|
155
155
|
case 0:
|
|
156
|
-
|
|
156
|
+
shouldNotify = _args.length > 2 && _args[2] !== undefined ? _args[2] : "auto";
|
|
157
157
|
if (this.canModify) {
|
|
158
158
|
_context.next = 7;
|
|
159
159
|
break;
|
|
@@ -176,24 +176,24 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
176
176
|
_classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, value);
|
|
177
177
|
isValueChanged = true;
|
|
178
178
|
} else isValueChanged = false;
|
|
179
|
-
//console.log("SV:", isValueChanged, oldval, key, value);
|
|
180
179
|
case 11:
|
|
181
180
|
_context.prev = 11;
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
console.log("set", key, value, shouldNotify);
|
|
182
|
+
if (!(shouldNotify === true || shouldNotify === "auto" && isValueChanged)) {
|
|
183
|
+
_context.next = 16;
|
|
184
184
|
break;
|
|
185
185
|
}
|
|
186
|
-
_context.next =
|
|
186
|
+
_context.next = 16;
|
|
187
187
|
return this.notifyChanged("", key, value);
|
|
188
|
-
case 15:
|
|
189
|
-
return _context.finish(11);
|
|
190
188
|
case 16:
|
|
191
|
-
return _context.
|
|
189
|
+
return _context.finish(11);
|
|
192
190
|
case 17:
|
|
191
|
+
return _context.abrupt("return", isValueChanged);
|
|
192
|
+
case 18:
|
|
193
193
|
case "end":
|
|
194
194
|
return _context.stop();
|
|
195
195
|
}
|
|
196
|
-
}, _callee, this, [[8,, 11,
|
|
196
|
+
}, _callee, this, [[8,, 11, 17]]);
|
|
197
197
|
}));
|
|
198
198
|
function setValue(_x, _x2) {
|
|
199
199
|
return _setValue.apply(this, arguments);
|
|
@@ -589,10 +589,19 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
589
589
|
return _pushValues.apply(this, arguments);
|
|
590
590
|
}
|
|
591
591
|
return pushValues;
|
|
592
|
-
}()
|
|
592
|
+
}()
|
|
593
|
+
/**
|
|
594
|
+
*
|
|
595
|
+
* @param type
|
|
596
|
+
* @param key
|
|
597
|
+
* @param value
|
|
598
|
+
* @param subvalue
|
|
599
|
+
* @returns true if manager was notified. false otherwise
|
|
600
|
+
*/
|
|
601
|
+
)
|
|
593
602
|
}, {
|
|
594
603
|
key: "notifyChanged",
|
|
595
|
-
value: function () {
|
|
604
|
+
value: (function () {
|
|
596
605
|
var _notifyChanged = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(type, key, value, subvalue) {
|
|
597
606
|
var lc, manager_class;
|
|
598
607
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
@@ -610,13 +619,17 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
610
619
|
this.__lastChanged = lc;
|
|
611
620
|
/* --------------------------- notify the manager --------------------------- */
|
|
612
621
|
manager_class = this.manager;
|
|
613
|
-
if (!(manager_class
|
|
614
|
-
_context11.next =
|
|
622
|
+
if (!(typeof (manager_class === null || manager_class === void 0 ? void 0 : manager_class.notifyChanged) === "function")) {
|
|
623
|
+
_context11.next = 11;
|
|
615
624
|
break;
|
|
616
625
|
}
|
|
617
626
|
_context11.next = 10;
|
|
618
627
|
return manager_class.notifyChanged(type, key, value, subvalue);
|
|
619
628
|
case 10:
|
|
629
|
+
return _context11.abrupt("return", _context11.sent);
|
|
630
|
+
case 11:
|
|
631
|
+
return _context11.abrupt("return", false);
|
|
632
|
+
case 12:
|
|
620
633
|
case "end":
|
|
621
634
|
return _context11.stop();
|
|
622
635
|
}
|
|
@@ -634,6 +647,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
634
647
|
* @param useExtraProps should we check extra props?
|
|
635
648
|
* @returns
|
|
636
649
|
*/
|
|
650
|
+
)
|
|
637
651
|
}, {
|
|
638
652
|
key: "apply_changes",
|
|
639
653
|
value: /* -------------------------------------------------------------------------- */
|
|
@@ -694,14 +708,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
694
708
|
key: "reset",
|
|
695
709
|
value: (function () {
|
|
696
710
|
var _reset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(key) {
|
|
697
|
-
var
|
|
711
|
+
var shouldNotify,
|
|
698
712
|
_args12 = arguments;
|
|
699
713
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
700
714
|
while (1) switch (_context12.prev = _context12.next) {
|
|
701
715
|
case 0:
|
|
702
|
-
|
|
716
|
+
shouldNotify = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : "auto";
|
|
703
717
|
_context12.next = 3;
|
|
704
|
-
return this.setValue(key, this[key],
|
|
718
|
+
return this.setValue(key, this[key], shouldNotify);
|
|
705
719
|
case 3:
|
|
706
720
|
return _context12.abrupt("return", _context12.sent);
|
|
707
721
|
case 4:
|
|
@@ -725,14 +739,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
725
739
|
key: "resetAll",
|
|
726
740
|
value: (function () {
|
|
727
741
|
var _resetAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
728
|
-
var
|
|
742
|
+
var shouldNotify,
|
|
729
743
|
fr,
|
|
730
744
|
key,
|
|
731
745
|
_args13 = arguments;
|
|
732
746
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
733
747
|
while (1) switch (_context13.prev = _context13.next) {
|
|
734
748
|
case 0:
|
|
735
|
-
|
|
749
|
+
shouldNotify = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : "auto";
|
|
736
750
|
fr = true;
|
|
737
751
|
_context13.t0 = _regeneratorRuntime().keys(this.__delta);
|
|
738
752
|
case 3:
|
|
@@ -747,7 +761,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
747
761
|
break;
|
|
748
762
|
}
|
|
749
763
|
_context13.next = 9;
|
|
750
|
-
return this.reset(key,
|
|
764
|
+
return this.reset(key, shouldNotify);
|
|
751
765
|
case 9:
|
|
752
766
|
_context13.t2 = _context13.sent;
|
|
753
767
|
case 10:
|
|
@@ -814,7 +828,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
814
828
|
if (!orig) return false; //we dont know if anything has changed
|
|
815
829
|
/* if object is not using delta mode, check changes by comparing changable fields with original object */
|
|
816
830
|
if (Array.isArray(this.__changeables)) {
|
|
817
|
-
//console.log("chk", this.__changeables, "for changes");
|
|
818
831
|
return this.__changeables.find(function (c) {
|
|
819
832
|
return !(0, _object.object_equals)(_this3[c], orig[c]);
|
|
820
833
|
}) != undefined;
|