sharedb 5.0.2 → 5.0.3
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/lib/client/doc.js +1 -1
- package/package.json +1 -1
- package/test/client/doc.js +21 -0
package/lib/client/doc.js
CHANGED
|
@@ -295,7 +295,7 @@ Doc.prototype._handleFetch = function(error, snapshot) {
|
|
|
295
295
|
var callbacks = this.pendingFetch;
|
|
296
296
|
this.pendingFetch = [];
|
|
297
297
|
var callback = this.inflightFetch.shift();
|
|
298
|
-
if (callback) callbacks.
|
|
298
|
+
if (callback) callbacks.unshift(callback);
|
|
299
299
|
if (callbacks.length) {
|
|
300
300
|
callback = function(error) {
|
|
301
301
|
util.callEach(callbacks, error);
|
package/package.json
CHANGED
package/test/client/doc.js
CHANGED
|
@@ -101,6 +101,27 @@ describe('Doc', function() {
|
|
|
101
101
|
doc.fetch(finish);
|
|
102
102
|
doc.fetch(finish);
|
|
103
103
|
});
|
|
104
|
+
it('callbacks called in correct order when fetching and applying ops in quick succession', function(done) {
|
|
105
|
+
var connection = this.connection;
|
|
106
|
+
var doc = connection.get('dogs', 'fido');
|
|
107
|
+
doc.create({name: 'fido'});
|
|
108
|
+
var order = '';
|
|
109
|
+
doc.fetch(function() {
|
|
110
|
+
order += 'A';
|
|
111
|
+
});
|
|
112
|
+
doc.submitOp([{p: ['snacks'], oi: true}]);
|
|
113
|
+
doc.fetch(function() {
|
|
114
|
+
order += 'B';
|
|
115
|
+
});
|
|
116
|
+
doc.submitOp([{p: ['color'], oi: 'gray'}]);
|
|
117
|
+
doc.fetch(function() {
|
|
118
|
+
order += 'C';
|
|
119
|
+
});
|
|
120
|
+
doc.whenNothingPending(function() {
|
|
121
|
+
expect(order).to.eql('ABC');
|
|
122
|
+
done();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
104
125
|
});
|
|
105
126
|
|
|
106
127
|
describe('when connection closed', function() {
|