ParseReact
ParseReact copied to clipboard
Observe: refresh with network error clears looses the data
Say I'm observing for MyObj, the data is populated and later refreshed. In case of error during the refresh, e.g. no network connection, the current data is lost.
Moreover, an Alert is thrown with "Received an error with invalid JSON from Parse: ..." (this should have changed in one of the latest commits -- in react-native appears on the user's screen).
Repro (with no network connection):
observe: function() {
return {
myobjs: (new Parse.Query('MyObj'))
};
},
componentDidMount: function() {
// initial data
var myobjs = [ /* some initial values here */ ];
this._receiveData('myobjs', myobjs);
},
I was able to work around by modifying Mixin.js as follows -- I can send a PR but would like to understand where you'd prefer to apply the patch (this doesn't look like a very good solution to me).
_receiveData: function _receiveData(name, value) {
if (typeof this.data[name] === 'undefined' || Object.prototype.toString.call(value) !== '[object Array]' || value.length > 0)
this.data[name] = value;
delete this._pendingQueries[name];
delete this._queryErrors[name];
this.forceUpdate();
},
Rather than handle it at the component level, I think we should handle it at the internal storage layer. As an initial fix, I'd say a failed subscription should not update its contents in any way. Down the road, we can query our local index of known objects to best-guess the result set. I'm exploring a number of offline support methods, so that developers can build better React Native apps.
That's great news! Is there a place to follow discussion, or a changelog to monitor what's getting added?
@andrewimm do you have any news? I've updated to 0.4.2 (and Parse to 1.5.0) but the issue seems still there.
Sorry, I haven't had much time to devote to new Parse+React features lately. I'll open up a discussion task on the matter of disk caching, though.