dataflux 1.2.0 → 1.2.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.
@@ -108,7 +108,7 @@ var ReactStore = /*#__PURE__*/function (_ObserverStore) {
108
108
  _createClass(ReactStore, [{
109
109
  key: "findAll",
110
110
  value: function findAll(type, stateAttribute, context, filterFunction) {
111
- _classPrivateMethodGet(this, _fixState, _fixState2).call(this, stateAttribute, context);
111
+ _classPrivateMethodGet(this, _fixState, _fixState2).call(this, stateAttribute, context, false);
112
112
 
113
113
  var subKey = this.subscribe(type, function (data) {
114
114
  context.setState(_objectSpread(_objectSpread({}, context.state), {}, _defineProperty({}, stateAttribute, data || [])));
@@ -118,7 +118,7 @@ var ReactStore = /*#__PURE__*/function (_ObserverStore) {
118
118
  }, {
119
119
  key: "findOne",
120
120
  value: function findOne(type, stateAttribute, context, filterFunction) {
121
- _classPrivateMethodGet(this, _fixState, _fixState2).call(this, stateAttribute, context);
121
+ _classPrivateMethodGet(this, _fixState, _fixState2).call(this, stateAttribute, context, true);
122
122
 
123
123
  var subKey = this.subscribe(type, function (data) {
124
124
  context.setState(_objectSpread(_objectSpread({}, context.state), {}, _defineProperty({}, stateAttribute, data && data.length ? data[0] : null)));
@@ -132,8 +132,8 @@ var ReactStore = /*#__PURE__*/function (_ObserverStore) {
132
132
 
133
133
  exports["default"] = ReactStore;
134
134
 
135
- function _fixState2(stateAttribute, context) {
135
+ function _fixState2(stateAttribute, context, one) {
136
136
  if (!context[stateAttribute]) {
137
- context[stateAttribute] = []; // side effect on state
137
+ context[stateAttribute] = one ? null : []; // side effect on state
138
138
  }
139
139
  }
@@ -58,7 +58,7 @@ var Obj = /*#__PURE__*/_createClass(function Obj(values, model) {
58
58
  });
59
59
 
60
60
  _defineProperty(this, "getFingerprint", function () {
61
- return (0, _fingerprint["default"])(_this.toJson());
61
+ return (0, _fingerprint["default"])(_this.toJSON());
62
62
  });
63
63
 
64
64
  _defineProperty(this, "get", function (attribute) {
@@ -87,7 +87,7 @@ var Obj = /*#__PURE__*/_createClass(function Obj(values, model) {
87
87
  return _this.getModel().getStore()["delete"]([_this]);
88
88
  });
89
89
 
90
- _defineProperty(this, "toJson", function () {
90
+ _defineProperty(this, "toJSON", function () {
91
91
  var attrs = Object.keys(_this);
92
92
  var out = {};
93
93
 
@@ -103,7 +103,7 @@ var Obj = /*#__PURE__*/_createClass(function Obj(values, model) {
103
103
  });
104
104
 
105
105
  _defineProperty(this, "toString", function () {
106
- return JSON.stringify(_this.toJson());
106
+ return JSON.stringify(_this.toJSON());
107
107
  });
108
108
 
109
109
  this.getModel = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dataflux",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "DataFlux, automatically interfaces with your REST APIs to create a 2-way-synced local data store. Transparently manages data propagation in the React state.",
5
5
  "main": "dist/index.js",
6
6
  "bin": "dist/index.js",