dataflux 1.9.5 → 1.10.2

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/README.md CHANGED
@@ -234,6 +234,8 @@ The method `findAll` returns always an array. The method `findOne` returns a sin
234
234
 
235
235
  When the component will unmount, the `findAll` subscription will be automatically terminated without the need to unsubscribe. Be aware, `store.findAll()` injects the unsubscribe call inside `componentWillUnmount()`. If your component already implements `componentWillUnmount()`, then you will have to use `store.subscribe()` and `store.unsubscribe()` instead of `store.findAll()`, to avoid side effects when the component is unmounted.
236
236
 
237
+ > Note: handleChange allows for type casting. E.g., store.handleChange(book, "pages", parseInt)
238
+
237
239
  In case you prefer React hooks:
238
240
 
239
241
  ```js
package/dist/BasicObj.js CHANGED
@@ -96,12 +96,12 @@ var BasicObj = /*#__PURE__*/function () {
96
96
  });
97
97
 
98
98
  _defineProperty(this, "setId", function (id) {
99
- _classPrivateFieldSet(_this, _id, id);
99
+ _this.id = id;
100
100
  });
101
101
 
102
102
  _defineProperty(this, "getId", function () {
103
103
  if (!_classPrivateFieldGet(_this, _id)) {
104
- if (_this.id && (typeof _this.id === "string" || typeof _this.id === "number")) {
104
+ if (_this.id != null && (typeof _this.id === "string" || typeof _this.id === "number")) {
105
105
  _classPrivateFieldSet(_this, _id, _this.id.toString());
106
106
 
107
107
  delete _this.setId;
package/dist/Model.js CHANGED
@@ -434,10 +434,11 @@ var Model = /*#__PURE__*/_createClass(function Model(name) {
434
434
  _classPrivateFieldInitSpec(this, _assignId, {
435
435
  writable: true,
436
436
  value: function value(data, objects) {
437
- if (data.length === 1 && objects.length === 1) {
438
- var newId = data[0].id;
439
- objects[0].setId(newId);
440
- delete objects[0].setId;
437
+ if (Array.isArray(data) && Array.isArray(objects) && objects.length === data.length) {
438
+ for (var i = 0; i < data.length; i++) {
439
+ objects[i].setId(data[i].id);
440
+ delete objects[i].setId;
441
+ }
441
442
  }
442
443
  }
443
444
  });
@@ -367,6 +367,10 @@ var ObserverStore = /*#__PURE__*/function (_PersistentStore) {
367
367
  _createClass(ObserverStore, [{
368
368
  key: "update",
369
369
  value: function update(objects, skipSave) {
370
+ if (!skipSave) {
371
+ _classPrivateFieldGet(this, _propagateChange).call(this, objects);
372
+ }
373
+
370
374
  return _get(_getPrototypeOf(ObserverStore.prototype), "update", this).call(this, objects, skipSave).then(_classPrivateFieldGet(this, _propagateChange));
371
375
  }
372
376
  }, {
@@ -108,12 +108,11 @@ var ReactStore = /*#__PURE__*/function (_ObserverStore) {
108
108
  }
109
109
  });
110
110
 
111
- _defineProperty(_assertThisInitialized(_this), "handleChange", function (object, name) {
111
+ _defineProperty(_assertThisInitialized(_this), "handleChange", function (object, name, cast) {
112
112
  return function (event, rawValue) {
113
- var _ref;
114
-
115
113
  var value = event ? event.target.type === "checkbox" ? event.target.checked : event.target.value : "";
116
- object.set(name, (_ref = value !== null && value !== void 0 ? value : rawValue) !== null && _ref !== void 0 ? _ref : "");
114
+ var finalValue = value !== null && value !== void 0 ? value : rawValue;
115
+ object.set(name, cast && finalValue != null ? cast(finalValue) : finalValue);
117
116
  };
118
117
  });
119
118