dataflux 1.19.8 → 1.21.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.
@@ -71,7 +71,6 @@ var PersistentStore = exports["default"] = /*#__PURE__*/function (_Store) {
71
71
  _defineProperty(_this, "_save", function () {
72
72
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
73
73
  _this._busy = true;
74
- _this.pubSub.publish("save", "start");
75
74
  if (_this._delayedSaveTimer) {
76
75
  clearTimeout(_this._delayedSaveTimer);
77
76
  }
@@ -82,11 +81,9 @@ var PersistentStore = exports["default"] = /*#__PURE__*/function (_Store) {
82
81
  return _this._saveByType(i, true);
83
82
  })).then(function (data) {
84
83
  _this._busy = false;
85
- _this.pubSub.publish("save", "end");
86
84
  return data;
87
85
  })["catch"](function (error) {
88
86
  _this._busy = false;
89
- _this.pubSub.publish("save", "end");
90
87
  _this.pubSub.publish("error", error);
91
88
  return Promise.reject(error);
92
89
  });
@@ -137,8 +134,18 @@ var PersistentStore = exports["default"] = /*#__PURE__*/function (_Store) {
137
134
  });
138
135
  });
139
136
  _defineProperty(_this, "_saveByType", function (type, ifLoaded) {
137
+ _this.pubSub.publish("save", {
138
+ status: "start",
139
+ model: type
140
+ });
140
141
  return _this.getDiff(type, ifLoaded).then(function (diff) {
141
142
  return _this._saveDiff(type, diff);
143
+ }).then(function (data) {
144
+ _this.pubSub.publish("save", {
145
+ status: "end",
146
+ model: type
147
+ });
148
+ return data;
142
149
  });
143
150
  });
144
151
  _defineProperty(_this, "delayedSave", function () {
@@ -81,7 +81,11 @@ var ReactStore = exports["default"] = /*#__PURE__*/function (_ObserverStore) {
81
81
  }
82
82
  return context.___obs_sync_state[key];
83
83
  } else {
84
- context.setState(_objectSpread(_objectSpread({}, context.state), {}, _defineProperty({}, key, null)));
84
+ setTimeout(function () {
85
+ return context.setState(function (prev) {
86
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, key, null));
87
+ });
88
+ }, 0);
85
89
  }
86
90
  });
87
91
  _defineProperty(_this, "didUpdate", function (context) {
@@ -140,9 +144,14 @@ var ReactStore = exports["default"] = /*#__PURE__*/function (_ObserverStore) {
140
144
  key: "findAll",
141
145
  value: function findAll(type, stateAttribute, context, filterFunction) {
142
146
  _assertClassBrand(_ReactStore_brand, this, _fixState).call(this, stateAttribute, context, false);
147
+ context._isMounted = true;
143
148
  var subKey = this.subscribe(type, function (data) {
144
- if (context._isMounted === undefined || context._isMounted) {
145
- context.setState(_objectSpread(_objectSpread({}, context.state), {}, _defineProperty({}, stateAttribute, data || [])));
149
+ if (context._isMounted) {
150
+ setTimeout(function () {
151
+ return context.setState(function (prev) {
152
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, stateAttribute, data || []));
153
+ });
154
+ }, 0);
146
155
  }
147
156
  }, filterFunction);
148
157
  _classPrivateFieldGet(_addSubscriptionToContext, this).call(this, context, subKey);
@@ -152,9 +161,12 @@ var ReactStore = exports["default"] = /*#__PURE__*/function (_ObserverStore) {
152
161
  key: "findOne",
153
162
  value: function findOne(type, stateAttribute, context, filterFunction) {
154
163
  _assertClassBrand(_ReactStore_brand, this, _fixState).call(this, stateAttribute, context, true);
164
+ context._isMounted = true;
155
165
  var subKey = this.subscribe(type, function (data) {
156
- if (context._isMounted === undefined || context._isMounted) {
157
- context.setState(_objectSpread(_objectSpread({}, context.state), {}, _defineProperty({}, stateAttribute, data && data.length ? data[0] : null)));
166
+ if (context._isMounted) {
167
+ setTimeout(context.setState(function (prev) {
168
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, stateAttribute, data && data.length ? data[0] : null));
169
+ }), 0);
158
170
  }
159
171
  }, filterFunction);
160
172
  _classPrivateFieldGet(_addSubscriptionToContext, this).call(this, context, subKey);