dataflux 1.9.3 → 1.10.0

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", Integer.parseInt)
238
+
237
239
  In case you prefer React hooks:
238
240
 
239
241
  ```js
package/dist/BasicObj.js CHANGED
@@ -12,12 +12,12 @@ var _uuid = require("uuid");
12
12
 
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
14
 
15
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
+
15
17
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16
18
 
17
19
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
18
20
 
19
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
-
21
21
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
22
 
23
23
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
@@ -69,137 +69,144 @@ var _error = /*#__PURE__*/new WeakMap();
69
69
 
70
70
  var _model = /*#__PURE__*/new WeakMap();
71
71
 
72
- var BasicObj = /*#__PURE__*/_createClass(function BasicObj(values, model) {
73
- var _this = this;
72
+ var BasicObj = /*#__PURE__*/function () {
73
+ function BasicObj(values, model) {
74
+ var _this = this;
75
+
76
+ _classCallCheck(this, BasicObj);
77
+
78
+ _classPrivateFieldInitSpec(this, _setHidden, {
79
+ writable: true,
80
+ value: {}
81
+ });
82
+
83
+ _classPrivateFieldInitSpec(this, _id, {
84
+ writable: true,
85
+ value: null
86
+ });
87
+
88
+ _classPrivateFieldInitSpec(this, _error, {
89
+ writable: true,
90
+ value: {}
91
+ });
92
+
93
+ _classPrivateFieldInitSpec(this, _model, {
94
+ writable: true,
95
+ value: void 0
96
+ });
97
+
98
+ _defineProperty(this, "setId", function (id) {
99
+ _classPrivateFieldSet(_this, _id, id);
100
+ });
101
+
102
+ _defineProperty(this, "getId", function () {
103
+ if (!_classPrivateFieldGet(_this, _id)) {
104
+ if (_this.id && (typeof _this.id === "string" || typeof _this.id === "number")) {
105
+ _classPrivateFieldSet(_this, _id, _this.id.toString());
106
+
107
+ delete _this.setId;
108
+ } else {
109
+ _classPrivateFieldSet(_this, _id, (0, _uuid.v4)());
110
+ }
111
+ }
74
112
 
75
- _classCallCheck(this, BasicObj);
113
+ return _classPrivateFieldGet(_this, _id);
114
+ });
76
115
 
77
- _classPrivateFieldInitSpec(this, _setHidden, {
78
- writable: true,
79
- value: {}
80
- });
116
+ _defineProperty(this, "get", function (attribute, defaultValue) {
117
+ var _ref, _classPrivateFieldGet2;
81
118
 
82
- _classPrivateFieldInitSpec(this, _id, {
83
- writable: true,
84
- value: null
85
- });
119
+ return (_ref = (_classPrivateFieldGet2 = _classPrivateFieldGet(_this, _setHidden)[attribute]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : _this[attribute]) !== null && _ref !== void 0 ? _ref : defaultValue;
120
+ });
86
121
 
87
- _classPrivateFieldInitSpec(this, _error, {
88
- writable: true,
89
- value: {}
90
- });
122
+ _defineProperty(this, "getError", function () {
123
+ var _classPrivateFieldGet3;
91
124
 
92
- _classPrivateFieldInitSpec(this, _model, {
93
- writable: true,
94
- value: void 0
95
- });
125
+ var attribute = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
126
+ var key = attribute ? attribute : globalError;
127
+ return (_classPrivateFieldGet3 = _classPrivateFieldGet(_this, _error)[key]) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : false;
128
+ });
96
129
 
97
- _defineProperty(this, "setId", function (id) {
98
- _classPrivateFieldSet(_this, _id, id);
99
- });
130
+ _defineProperty(this, "setError", function (error) {
131
+ var attribute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
100
132
 
101
- _defineProperty(this, "getId", function () {
102
- if (!_classPrivateFieldGet(_this, _id)) {
103
- if (_this.id && (typeof _this.id === "string" || typeof _this.id === "number")) {
104
- _classPrivateFieldSet(_this, _id, _this.id.toString());
105
-
106
- delete _this.setId;
133
+ if (error && attribute) {
134
+ _classPrivateFieldGet(_this, _error)[attribute] = error;
135
+ } else if (error && !attribute) {
136
+ _classPrivateFieldGet(_this, _error)[globalError] = error;
137
+ } else if (!error && attribute) {
138
+ delete _classPrivateFieldGet(_this, _error)[attribute];
107
139
  } else {
108
- _classPrivateFieldSet(_this, _id, (0, _uuid.v4)());
140
+ _classPrivateFieldSet(_this, _error, {});
109
141
  }
110
- }
111
-
112
- return _classPrivateFieldGet(_this, _id);
113
- });
114
-
115
- _defineProperty(this, "get", function (attribute, defaultValue) {
116
- var _ref, _classPrivateFieldGet2;
117
-
118
- return (_ref = (_classPrivateFieldGet2 = _classPrivateFieldGet(_this, _setHidden)[attribute]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : _this[attribute]) !== null && _ref !== void 0 ? _ref : defaultValue;
119
- });
120
-
121
- _defineProperty(this, "set", function (attribute, value, hidden) {
122
- if (hidden) {
123
- _classPrivateFieldGet(_this, _setHidden)[attribute] = value;
124
- } else {
125
- if (attribute === "id") {
126
- throw new Error("You cannot change the ID");
142
+ });
143
+
144
+ _defineProperty(this, "setConstant", function (attribute, value) {
145
+ var _classPrivateFieldGet4;
146
+
147
+ _classPrivateFieldGet(_this, _setHidden)[attribute] = (_classPrivateFieldGet4 = _classPrivateFieldGet(_this, _setHidden)[attribute]) !== null && _classPrivateFieldGet4 !== void 0 ? _classPrivateFieldGet4 : value;
148
+ });
149
+
150
+ _defineProperty(this, "toJSON", function () {
151
+ var attrs = Object.keys(_this);
152
+ var out = {};
153
+
154
+ for (var _i = 0, _attrs = attrs; _i < _attrs.length; _i++) {
155
+ var a = _attrs[_i];
156
+
157
+ if (_this[a] == null) {
158
+ out[a] = _this[a];
159
+ } else if (_this[a] instanceof _moment["default"]) {
160
+ out[a] = _this[a].toISOString();
161
+ } else if (_this[a] instanceof Date) {
162
+ out[a] = (0, _moment["default"])(_this[a]).toISOString();
163
+ } else if (_typeof(_this[a]) === "object" && _this[a].toJSON) {
164
+ out[a] = _this[a].toJSON();
165
+ } else if (Array.isArray(_this[a]) && _this[a].every(function (i) {
166
+ return _typeof(i) === "object" && i.toJSON;
167
+ })) {
168
+ out[a] = _this[a].map(function (i) {
169
+ return i.toJSON();
170
+ });
171
+ } else if (typeof _this[a] !== "function") {
172
+ out[a] = _this[a];
173
+ }
127
174
  }
128
175
 
129
- _this[attribute] = value;
176
+ return out;
177
+ });
130
178
 
131
- _classPrivateFieldGet(_this, _model).validateObjectAttribute(_this, attribute);
132
- }
133
-
134
- return _this.update();
135
- });
179
+ _defineProperty(this, "toString", function () {
180
+ return JSON.stringify(_this.toJSON());
181
+ });
136
182
 
137
- _defineProperty(this, "getError", function () {
138
- var _classPrivateFieldGet3;
139
-
140
- var attribute = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
141
- var key = attribute ? attribute : globalError;
142
- return (_classPrivateFieldGet3 = _classPrivateFieldGet(_this, _error)[key]) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : false;
143
- });
183
+ _defineProperty(this, "update", function () {
184
+ return Promise.resolve();
185
+ });
144
186
 
145
- _defineProperty(this, "setError", function (error) {
146
- var attribute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
187
+ _classPrivateFieldSet(this, _model, model);
188
+ }
147
189
 
148
- if (error && attribute) {
149
- _classPrivateFieldGet(_this, _error)[attribute] = error;
150
- } else if (error && !attribute) {
151
- _classPrivateFieldGet(_this, _error)[globalError] = error;
152
- } else if (!error && attribute) {
153
- delete _classPrivateFieldGet(_this, _error)[attribute];
154
- } else {
155
- _classPrivateFieldSet(_this, _error, {});
156
- }
157
- });
190
+ _createClass(BasicObj, [{
191
+ key: "set",
192
+ value: function set(attribute, value, hidden) {
193
+ if (hidden) {
194
+ _classPrivateFieldGet(this, _setHidden)[attribute] = value;
195
+ } else {
196
+ if (attribute === "id") {
197
+ throw new Error("You cannot change the ID");
198
+ }
158
199
 
159
- _defineProperty(this, "setConstant", function (attribute, value) {
160
- var _classPrivateFieldGet4;
200
+ this[attribute] = value;
161
201
 
162
- _classPrivateFieldGet(_this, _setHidden)[attribute] = (_classPrivateFieldGet4 = _classPrivateFieldGet(_this, _setHidden)[attribute]) !== null && _classPrivateFieldGet4 !== void 0 ? _classPrivateFieldGet4 : value;
163
- });
164
-
165
- _defineProperty(this, "toJSON", function () {
166
- var attrs = Object.keys(_this);
167
- var out = {};
168
-
169
- for (var _i = 0, _attrs = attrs; _i < _attrs.length; _i++) {
170
- var a = _attrs[_i];
171
-
172
- if (_this[a] == null) {
173
- out[a] = _this[a];
174
- } else if (_this[a] instanceof _moment["default"]) {
175
- out[a] = _this[a].toISOString();
176
- } else if (_this[a] instanceof Date) {
177
- out[a] = (0, _moment["default"])(_this[a]).toISOString();
178
- } else if (_typeof(_this[a]) === "object" && _this[a].toJSON) {
179
- out[a] = _this[a].toJSON();
180
- } else if (Array.isArray(_this[a]) && _this[a].every(function (i) {
181
- return _typeof(i) === "object" && i.toJSON;
182
- })) {
183
- out[a] = _this[a].map(function (i) {
184
- return i.toJSON();
185
- });
186
- } else if (typeof _this[a] !== "function") {
187
- out[a] = _this[a];
202
+ _classPrivateFieldGet(this, _model).validateObjectAttribute(this, attribute);
188
203
  }
189
- }
190
204
 
191
- return out;
192
- });
193
-
194
- _defineProperty(this, "toString", function () {
195
- return JSON.stringify(_this.toJSON());
196
- });
197
-
198
- _defineProperty(this, "update", function () {
199
- return Promise.resolve();
200
- });
205
+ return this.update();
206
+ }
207
+ }]);
201
208
 
202
- _classPrivateFieldSet(this, _model, model);
203
- });
209
+ return BasicObj;
210
+ }();
204
211
 
205
212
  exports.BasicObj = BasicObj;
package/dist/Model.js CHANGED
@@ -416,7 +416,9 @@ var Model = /*#__PURE__*/_createClass(function Model(name) {
416
416
  value: function value(objects) {
417
417
  var operation = "insert";
418
418
  return (0, _modelHooksUtils.executeHook)(operation, _classPrivateFieldGet(_this, _insertHook), _classPrivateFieldGet(_this, _unWrap).call(_this, objects), _classPrivateFieldGet(_this, _axios)).then(function (data) {
419
- if (data) _classPrivateFieldGet(_this, _assignId).call(_this, data, objects);
419
+ if (data) {
420
+ _classPrivateFieldGet(_this, _assignId).call(_this, data, objects);
421
+ }
420
422
 
421
423
  _classPrivateFieldGet(_this, _cleanApiError).call(_this, objects);
422
424
 
@@ -432,7 +434,7 @@ var Model = /*#__PURE__*/_createClass(function Model(name) {
432
434
  _classPrivateFieldInitSpec(this, _assignId, {
433
435
  writable: true,
434
436
  value: function value(data, objects) {
435
- if (data.length === 1) {
437
+ if (data.length === 1 && objects.length === 1) {
436
438
  var newId = data[0].id;
437
439
  objects[0].setId(newId);
438
440
  delete objects[0].setId;
package/dist/Obj.js CHANGED
@@ -23,7 +23,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
23
23
 
24
24
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
25
25
 
26
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
26
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
27
27
 
28
28
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
29
29
 
@@ -33,7 +33,11 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
33
33
 
34
34
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
35
35
 
36
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
36
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
37
+
38
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
39
+
40
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
37
41
 
38
42
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
39
43
 
@@ -59,7 +63,7 @@ var Obj = /*#__PURE__*/function (_BasicObj) {
59
63
  var _super = _createSuper(Obj);
60
64
 
61
65
  function Obj(values, _model) {
62
- var _this;
66
+ var _thisSuper, _this;
63
67
 
64
68
  _classCallCheck(this, Obj);
65
69
 
@@ -70,6 +74,16 @@ var Obj = /*#__PURE__*/function (_BasicObj) {
70
74
  value: false
71
75
  });
72
76
 
77
+ _defineProperty(_assertThisInitialized(_this), "set", function (attribute, value, hidden) {
78
+ if (Array.isArray(value) && _this.getModel().options.deep) {
79
+ value = value.map(function (i) {
80
+ return i !== null && i !== void 0 && i.getId ? i : new _SubObj["default"](_assertThisInitialized(_this), "property", i, _this.getModel());
81
+ });
82
+ }
83
+
84
+ return _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(Obj.prototype)), "set", _thisSuper).call(_thisSuper, attribute, value, hidden);
85
+ });
86
+
73
87
  _defineProperty(_assertThisInitialized(_this), "load", function () {
74
88
  if (_classPrivateFieldGet(_assertThisInitialized(_this), _loaded)) {
75
89
  return Promise.resolve(_assertThisInitialized(_this));
@@ -35,13 +35,13 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
35
35
 
36
36
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
37
 
38
- function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
38
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
39
39
 
40
40
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
41
41
 
42
42
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
43
43
 
44
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
44
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
45
45
 
46
46
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
47
47
 
@@ -51,7 +51,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
51
51
 
52
52
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
53
53
 
54
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
54
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
55
55
 
56
56
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
57
57
 
@@ -81,6 +81,8 @@ var _getUniqueSubs = /*#__PURE__*/new WeakMap();
81
81
 
82
82
  var _propagateChange = /*#__PURE__*/new WeakMap();
83
83
 
84
+ var _appendIfNotExistent = /*#__PURE__*/new WeakMap();
85
+
84
86
  var _subscribeToObjects = /*#__PURE__*/new WeakMap();
85
87
 
86
88
  var _merge = /*#__PURE__*/new WeakMap();
@@ -167,40 +169,41 @@ var ObserverStore = /*#__PURE__*/function (_PersistentStore) {
167
169
  });
168
170
 
169
171
  _defineProperty(_assertThisInitialized(_this), "unsubscribe", function (key) {
170
- if (_classPrivateFieldGet(_assertThisInitialized(_this), _queryPromises).length) {
171
- _classPrivateFieldSet(_assertThisInitialized(_this), _unsubPromises, Promise.all(_classPrivateFieldGet(_assertThisInitialized(_this), _queryPromises)).then(function () {
172
- if (_this._multipleSubscribed[key]) {
173
- var _iterator = _createForOfIteratorHelper(_this._multipleSubscribed[key]),
174
- _step;
172
+ _classPrivateFieldSet(_assertThisInitialized(_this), _unsubPromises, (_classPrivateFieldGet(_assertThisInitialized(_this), _queryPromises).length ? Promise.all(_classPrivateFieldGet(_assertThisInitialized(_this), _queryPromises)) : Promise.resolve()).then(function () {
173
+ if (_this._multipleSubscribed[key]) {
174
+ var _iterator = _createForOfIteratorHelper(_this._multipleSubscribed[key]),
175
+ _step;
175
176
 
176
- try {
177
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
178
- var sub = _step.value;
177
+ try {
178
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
179
+ var sub = _step.value;
179
180
 
180
- _this.unsubscribe(sub);
181
- }
182
- } catch (err) {
183
- _iterator.e(err);
184
- } finally {
185
- _iterator.f();
181
+ _this.unsubscribe(sub);
186
182
  }
183
+ } catch (err) {
184
+ _iterator.e(err);
185
+ } finally {
186
+ _iterator.f();
187
+ }
187
188
 
188
- delete _this._multipleSubscribed[key];
189
- } else {
190
- for (var type in _this._subscribed) {
191
- for (var id in _this._subscribed[type]) {
192
- _this._subscribed[type][id] = _this._subscribed[type][id].filter(function (i) {
193
- return i.subKey !== key;
194
- });
195
-
196
- if (_this._subscribed[type][id].length === 0) {
197
- delete _this._subscribed[type][id];
198
- }
189
+ delete _this._multipleSubscribed[key];
190
+ } else {
191
+ for (var type in _this._subscribed) {
192
+ for (var id in _this._subscribed[type]) {
193
+ _this._subscribed[type][id] = _this._subscribed[type][id].filter(function (i) {
194
+ return i.subKey !== key;
195
+ });
196
+ _this._subscribed[type]["*"] = _this._subscribed[type]["*"].filter(function (i) {
197
+ return i.subKey !== key;
198
+ });
199
+
200
+ if (_this._subscribed[type][id].length === 0) {
201
+ delete _this._subscribed[type][id];
199
202
  }
200
203
  }
201
204
  }
202
- }));
203
- }
205
+ }
206
+ }));
204
207
  });
205
208
 
206
209
  _classPrivateFieldInitSpec(_assertThisInitialized(_this), _getUniqueSubs, {
@@ -266,27 +269,45 @@ var ObserverStore = /*#__PURE__*/function (_PersistentStore) {
266
269
  }
267
270
  });
268
271
 
272
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _appendIfNotExistent, {
273
+ writable: true,
274
+ value: function value(arr, item) {
275
+ if (Object.values(arr).filter(function (_ref4) {
276
+ var subKey = _ref4.subKey;
277
+ return item.subKey === subKey;
278
+ }).length === 0) {
279
+ arr.push(item);
280
+ }
281
+ }
282
+ });
283
+
269
284
  _classPrivateFieldInitSpec(_assertThisInitialized(_this), _subscribeToObjects, {
270
285
  writable: true,
271
286
  value: function value(type, objectsToSubscribe, item) {
287
+ var _this$_subscribed$typ2, _, _this$_subscribed$typ3;
288
+
272
289
  var _iterator4 = _createForOfIteratorHelper(objectsToSubscribe),
273
290
  _step4;
274
291
 
275
292
  try {
276
293
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
277
- var _this$_subscribed$typ2, _this$_subscribed$typ3;
294
+ var _this$_subscribed$typ4, _this$_subscribed$typ5;
278
295
 
279
296
  var object = _step4.value;
280
297
  var id = object.getId();
281
- (_this$_subscribed$typ3 = (_this$_subscribed$typ2 = _this._subscribed[type])[id]) !== null && _this$_subscribed$typ3 !== void 0 ? _this$_subscribed$typ3 : _this$_subscribed$typ2[id] = [];
298
+ (_this$_subscribed$typ5 = (_this$_subscribed$typ4 = _this._subscribed[type])[id]) !== null && _this$_subscribed$typ5 !== void 0 ? _this$_subscribed$typ5 : _this$_subscribed$typ4[id] = [];
282
299
 
283
- _this._subscribed[type][id].push(item);
300
+ _classPrivateFieldGet(_assertThisInitialized(_this), _appendIfNotExistent).call(_assertThisInitialized(_this), _this._subscribed[type][id], item);
284
301
  }
285
302
  } catch (err) {
286
303
  _iterator4.e(err);
287
304
  } finally {
288
305
  _iterator4.f();
289
306
  }
307
+
308
+ (_this$_subscribed$typ3 = (_this$_subscribed$typ2 = _this._subscribed[type])[_ = "*"]) !== null && _this$_subscribed$typ3 !== void 0 ? _this$_subscribed$typ3 : _this$_subscribed$typ2[_] = [];
309
+
310
+ _classPrivateFieldGet(_assertThisInitialized(_this), _appendIfNotExistent).call(_assertThisInitialized(_this), _this._subscribed[type]["*"], item);
290
311
  }
291
312
  });
292
313
 
@@ -297,11 +318,11 @@ var ObserverStore = /*#__PURE__*/function (_PersistentStore) {
297
318
  model: type
298
319
  });
299
320
 
300
- return _this.refreshObjectByType(type).then(function (_ref4) {
301
- var _ref5 = _slicedToArray(_ref4, 3),
302
- inserted = _ref5[0],
303
- updated = _ref5[1],
304
- deleted = _ref5[2];
321
+ return _this.refreshObjectByType(type).then(function (_ref5) {
322
+ var _ref6 = _slicedToArray(_ref5, 3),
323
+ inserted = _ref6[0],
324
+ updated = _ref6[1],
325
+ deleted = _ref6[2];
305
326
 
306
327
  var item = _this.models[type];
307
328
  return Promise.all([_classPrivateMethodGet(_assertThisInitialized(_this), _propagateInsertChange, _propagateInsertChange2).call(_assertThisInitialized(_this), type, inserted), _classPrivateFieldGet(_assertThisInitialized(_this), _propagateChange).call(_assertThisInitialized(_this), updated), _classPrivateFieldGet(_assertThisInitialized(_this), _propagateChange).call(_assertThisInitialized(_this), deleted)]).then(function () {
@@ -412,34 +433,15 @@ function _propagateInsertChange2(type, newObjects) {
412
433
  }
413
434
 
414
435
  var possibleSubs = Object.values(uniqueSubs);
415
- (0, _batchPromises["default"])(10, possibleSubs, function (_ref6) {
416
- var callback = _ref6.callback,
417
- filterFunction = _ref6.filterFunction;
436
+ (0, _batchPromises["default"])(10, possibleSubs, function (_ref7) {
437
+ var callback = _ref7.callback,
438
+ filterFunction = _ref7.filterFunction,
439
+ subKey = _ref7.subKey;
418
440
  var objectsToSubscribe = filterFunction ? newObjects.filter(filterFunction) : newObjects;
419
441
 
420
442
  if (objectsToSubscribe.length) {
421
443
  // Check if the new objects matter
422
444
  return _this4.find(type, filterFunction).then(function (data) {
423
- var subKey;
424
-
425
- var _iterator6 = _createForOfIteratorHelper(data),
426
- _step6;
427
-
428
- try {
429
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
430
- var d = _step6.value;
431
-
432
- var item = _this4._subscribed[d.getModel().getType()][d.getId()];
433
-
434
- subKey = item ? item.subKey : null;
435
- if (subKey) break;
436
- }
437
- } catch (err) {
438
- _iterator6.e(err);
439
- } finally {
440
- _iterator6.f();
441
- }
442
-
443
445
  _classPrivateFieldGet(_this4, _subscribeToObjects).call(_this4, type, objectsToSubscribe, {
444
446
  callback: callback,
445
447
  filterFunction: filterFunction,
@@ -23,13 +23,13 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
23
23
 
24
24
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
25
25
 
26
- function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
26
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
27
27
 
28
28
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
29
29
 
30
30
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
31
 
32
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
33
 
34
34
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
35
 
@@ -39,7 +39,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
39
39
 
40
40
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
41
 
42
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
43
 
44
44
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
45
45
 
@@ -29,7 +29,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
29
29
 
30
30
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
31
 
32
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
33
 
34
34
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
35
 
@@ -39,7 +39,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
39
39
 
40
40
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
41
 
42
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
43
 
44
44
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
45
45
 
@@ -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