Skip to content

Commit f06960f

Browse files
committed
Moved hasLocalChanges to Bucket with a callback, and overridden by channel.
Bumped version and updated the test.
1 parent 61a8052 commit f06960f

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simperium",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "A simperium client for node.js",
55
"main": "./lib/simperium/index.js",
66
"repository": {

src/simperium/bucket.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Bucket.prototype.update = function( id, data, options, callback ) {
3131
return this.store.update( id, data, this.isIndexing, callback );
3232
};
3333

34+
Bucket.prototype.hasLocalChanges = function( callback ) {
35+
callback( false );
36+
};
37+
3438
Bucket.prototype.getVersion = function( id, callback ) {
3539
callback( null, 0 );
3640
};

src/simperium/channel.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ export default function Channel( appid, access_token, bucket, store ) {
293293
collectionRevisions( channel, id, callback );
294294
};
295295

296+
bucket.hasLocalChanges = function( callback ) {
297+
callback( channel.localQueue.hasChanges() );
298+
};
299+
296300
bucket.getVersion = function( id, callback ) {
297301
store.get( id ).then(
298302
( ghost ) => {

src/simperium/client.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ Client.prototype.bucket = function( name ) {
7171

7272
if ( this.open ) channel.onConnect();
7373

74-
bucket.hasLocalChanges = function() {
75-
return channel.localQueue.hasChanges();
76-
};
77-
7874
return bucket;
7975
};
8076

test/simperium/channel_test.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -312,24 +312,14 @@ describe( 'Channel', function() {
312312

313313
it( 'should have local changes on send', function( done ) {
314314
channel.once( 'send', function() {
315-
assert.equal( channel.localQueue.hasChanges(), true );
316-
done();
317-
} );
318-
319-
store.put( '123', 3, {title: 'hello world'} ).then( function() {
320-
bucket.update( '123', {title: 'goodbye world!!'} );
321-
} );
322-
} );
323-
324-
it( 'should have no local changes after ack', function( done ) {
325-
channel.on( 'acknowledge', function() {
326-
assert.equal( channel.localQueue.hasChanges(), false );
327-
done();
315+
bucket.hasLocalChanges( hasChanges => {
316+
assert.equal( hasChanges, true );
317+
done();
318+
} );
328319
} );
329320

330321
store.put( '123', 3, {title: 'hello world'} ).then( function() {
331322
bucket.update( '123', {title: 'goodbye world!!'} );
332-
done();
333323
} );
334324
} );
335325

0 commit comments

Comments
 (0)