dataflux 1.20.0 → 1.21.1

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
  });
@@ -138,7 +135,22 @@ var PersistentStore = exports["default"] = /*#__PURE__*/function (_Store) {
138
135
  });
139
136
  _defineProperty(_this, "_saveByType", function (type, ifLoaded) {
140
137
  return _this.getDiff(type, ifLoaded).then(function (diff) {
141
- return _this._saveDiff(type, diff);
138
+ var someChanges = diff.inserted.length > 0 || diff.updated.length > 0 || diff.deleted.length > 0;
139
+ if (someChanges) {
140
+ _this.pubSub.publish("save", {
141
+ status: "start",
142
+ model: type
143
+ });
144
+ }
145
+ return _this._saveDiff(type, diff).then(function (data) {
146
+ if (someChanges) {
147
+ _this.pubSub.publish("save", {
148
+ status: "end",
149
+ model: type
150
+ });
151
+ }
152
+ return data;
153
+ });
142
154
  });
143
155
  });
144
156
  _defineProperty(_this, "delayedSave", function () {