@azrico/webobject 1.4.145 → 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,8 +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, sendChanges?: sendChangesType): Promise<boolean>;
56
- set: (key: WriteablePropOf<this>, value: any, sendChanges?: sendChangesType) => Promise<boolean>;
55
+ setValue(key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType): Promise<boolean>;
56
+ /**
57
+ * set value
58
+ * @param key
59
+ * @param value
60
+ * @return true if changed , false otherwise
61
+ */
62
+ set: (key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType) => Promise<boolean>;
57
63
  setTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
58
64
  clearRefreshFunction(): Promise<void>;
59
65
  setRefreshFunction(new_fnc: any): Promise<any>;
@@ -114,7 +120,15 @@ export declare class SimpleObject extends MapableObject {
114
120
  * @returns
115
121
  */
116
122
  pushValues<MKey extends PropOf<this>>(key: MKey, values: any[], sendChanges?: sendChangesType): Promise<this[MKey] | false>;
117
- notifyChanged<MKey extends PropOf<this>>(type: string, key: MKey | string, value: any, subvalue?: any): Promise<void>;
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>;
118
132
  /**
119
133
  * check if a key can be changed on an object
120
134
  * @param object the object we are checking
@@ -141,13 +155,13 @@ export declare class SimpleObject extends MapableObject {
141
155
  * set the value to its original
142
156
  * @param key
143
157
  */
144
- reset(key: WriteablePropOf<this>, notifyChanged?: sendChangesType): Promise<boolean>;
158
+ reset(key: WriteablePropOf<this>, shouldNotify?: sendChangesType): Promise<boolean>;
145
159
  /**
146
160
  * reset all values back to their original
147
161
  * difference between this and clear_changes is that this function also calls on_change
148
162
  * @param key
149
163
  */
150
- resetAll(notifyChanged?: sendChangesType): Promise<boolean>;
164
+ resetAll(shouldNotify?: sendChangesType): Promise<boolean>;
151
165
  /**
152
166
  * clear and discard all changes
153
167
  * does not call any on_change functions
@@ -92,6 +92,12 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
92
92
  _defineProperty(_assertThisInitialized(_this), "_index_value", -1);
93
93
  _defineProperty(_assertThisInitialized(_this), "getValue", _classPrivateMethodGet(_assertThisInitialized(_this), _getProperty, _getProperty2));
94
94
  _defineProperty(_assertThisInitialized(_this), "get", _classPrivateMethodGet(_assertThisInitialized(_this), _getProperty, _getProperty2));
95
+ /**
96
+ * set value
97
+ * @param key
98
+ * @param value
99
+ * @return true if changed , false otherwise
100
+ */
95
101
  _defineProperty(_assertThisInitialized(_this), "set", _this.setValue);
96
102
  /**
97
103
  * set value of a key to now date time
@@ -140,14 +146,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
140
146
  */
141
147
  function () {
142
148
  var _setValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
143
- var sendChanges,
149
+ var shouldNotify,
144
150
  isValueChanged,
145
151
  oldval,
146
152
  _args = arguments;
147
153
  return _regeneratorRuntime().wrap(function _callee$(_context) {
148
154
  while (1) switch (_context.prev = _context.next) {
149
155
  case 0:
150
- sendChanges = _args.length > 2 && _args[2] !== undefined ? _args[2] : "auto";
156
+ shouldNotify = _args.length > 2 && _args[2] !== undefined ? _args[2] : "auto";
151
157
  if (this.canModify) {
152
158
  _context.next = 7;
153
159
  break;
@@ -170,24 +176,24 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
170
176
  _classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, value);
171
177
  isValueChanged = true;
172
178
  } else isValueChanged = false;
173
- //console.log("SV:", isValueChanged, oldval, key, value);
174
179
  case 11:
175
180
  _context.prev = 11;
176
- if (!(sendChanges === true || sendChanges === "auto" && isValueChanged)) {
177
- _context.next = 15;
181
+ console.log("set", key, value, shouldNotify);
182
+ if (!(shouldNotify === true || shouldNotify === "auto" && isValueChanged)) {
183
+ _context.next = 16;
178
184
  break;
179
185
  }
180
- _context.next = 15;
186
+ _context.next = 16;
181
187
  return this.notifyChanged("", key, value);
182
- case 15:
183
- return _context.finish(11);
184
188
  case 16:
185
- return _context.abrupt("return", isValueChanged);
189
+ return _context.finish(11);
186
190
  case 17:
191
+ return _context.abrupt("return", isValueChanged);
192
+ case 18:
187
193
  case "end":
188
194
  return _context.stop();
189
195
  }
190
- }, _callee, this, [[8,, 11, 16]]);
196
+ }, _callee, this, [[8,, 11, 17]]);
191
197
  }));
192
198
  function setValue(_x, _x2) {
193
199
  return _setValue.apply(this, arguments);
@@ -583,10 +589,19 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
583
589
  return _pushValues.apply(this, arguments);
584
590
  }
585
591
  return pushValues;
586
- }())
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
+ )
587
602
  }, {
588
603
  key: "notifyChanged",
589
- value: function () {
604
+ value: (function () {
590
605
  var _notifyChanged = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(type, key, value, subvalue) {
591
606
  var lc, manager_class;
592
607
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
@@ -604,13 +619,17 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
604
619
  this.__lastChanged = lc;
605
620
  /* --------------------------- notify the manager --------------------------- */
606
621
  manager_class = this.manager;
607
- if (!(manager_class instanceof _ObjectManager["default"])) {
608
- _context11.next = 10;
622
+ if (!(typeof (manager_class === null || manager_class === void 0 ? void 0 : manager_class.notifyChanged) === "function")) {
623
+ _context11.next = 11;
609
624
  break;
610
625
  }
611
626
  _context11.next = 10;
612
627
  return manager_class.notifyChanged(type, key, value, subvalue);
613
628
  case 10:
629
+ return _context11.abrupt("return", _context11.sent);
630
+ case 11:
631
+ return _context11.abrupt("return", false);
632
+ case 12:
614
633
  case "end":
615
634
  return _context11.stop();
616
635
  }
@@ -628,6 +647,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
628
647
  * @param useExtraProps should we check extra props?
629
648
  * @returns
630
649
  */
650
+ )
631
651
  }, {
632
652
  key: "apply_changes",
633
653
  value: /* -------------------------------------------------------------------------- */
@@ -688,14 +708,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
688
708
  key: "reset",
689
709
  value: (function () {
690
710
  var _reset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(key) {
691
- var notifyChanged,
711
+ var shouldNotify,
692
712
  _args12 = arguments;
693
713
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
694
714
  while (1) switch (_context12.prev = _context12.next) {
695
715
  case 0:
696
- notifyChanged = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : "auto";
716
+ shouldNotify = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : "auto";
697
717
  _context12.next = 3;
698
- return this.setValue(key, this[key], notifyChanged);
718
+ return this.setValue(key, this[key], shouldNotify);
699
719
  case 3:
700
720
  return _context12.abrupt("return", _context12.sent);
701
721
  case 4:
@@ -719,14 +739,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
719
739
  key: "resetAll",
720
740
  value: (function () {
721
741
  var _resetAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
722
- var notifyChanged,
742
+ var shouldNotify,
723
743
  fr,
724
744
  key,
725
745
  _args13 = arguments;
726
746
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
727
747
  while (1) switch (_context13.prev = _context13.next) {
728
748
  case 0:
729
- notifyChanged = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : "auto";
749
+ shouldNotify = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : "auto";
730
750
  fr = true;
731
751
  _context13.t0 = _regeneratorRuntime().keys(this.__delta);
732
752
  case 3:
@@ -741,7 +761,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
741
761
  break;
742
762
  }
743
763
  _context13.next = 9;
744
- return this.reset(key, notifyChanged);
764
+ return this.reset(key, shouldNotify);
745
765
  case 9:
746
766
  _context13.t2 = _context13.sent;
747
767
  case 10:
@@ -808,7 +828,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
808
828
  if (!orig) return false; //we dont know if anything has changed
809
829
  /* if object is not using delta mode, check changes by comparing changable fields with original object */
810
830
  if (Array.isArray(this.__changeables)) {
811
- //console.log("chk", this.__changeables, "for changes");
812
831
  return this.__changeables.find(function (c) {
813
832
  return !(0, _object.object_equals)(_this3[c], orig[c]);
814
833
  }) != undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.145",
3
+ "version": "1.4.147",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",