Skip to content

Commit 560e719

Browse files
committed
Adds jsdoc to public channel methods
1 parent 36a0f2f commit 560e719

File tree

2 files changed

+240
-44
lines changed

2 files changed

+240
-44
lines changed

src/simperium/bucket.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Bucket.prototype.setChannel = function( channel ) {
9494
.on( 'remove', this.onChannelRemove );
9595
};
9696

97+
/**
98+
* Reloads all the data from Simperium
99+
*/
97100
Bucket.prototype.reload = function() {
98101
this.channel.reload();
99102
};
@@ -116,7 +119,7 @@ Bucket.prototype.add = function( object, callback ) {
116119
*
117120
* @param {String} id - bucket object id
118121
* @param {Function} callback - with the data stored in the bucket
119-
* @return {Promise<Object>} the object data for the given id
122+
* @return {Promise<Object>} the object id, data and indexing status
120123
*/
121124
Bucket.prototype.get = function( id, callback ) {
122125
return deprecateCallback( callback, this.storeAPI.get( id ) );
@@ -151,21 +154,51 @@ Bucket.prototype.update = function( id, data, options, callback ) {
151154
return deprecateCallback( callback, task );
152155
};
153156

157+
/**
158+
* Check if the bucket has pending changes that have not yet been synced.
159+
*
160+
* @param {Function} [callback] - optional callback to receive response
161+
* @returns {Promise<Boolean>} resolves to true if their are still changes to sync
162+
*/
154163
Bucket.prototype.hasLocalChanges = function( callback ) {
155164
return deprecateCallback( callback, this.channel.hasLocalChanges() );
156165
};
157166

167+
/**
168+
* Gets the currently synced version number for the specified object id.
169+
*
170+
* A version of `0` indicates that an object has not been added to simperium yet.
171+
*
172+
* @param {String} id - object to get the version for
173+
* @param {Function} [callback] - optional callback
174+
* @returns {Promise<number>} - resolves to the current synced version
175+
*/
158176
Bucket.prototype.getVersion = function( id, callback ) {
159177
return deprecateCallback( callback, this.channel.getVersion( id ) );
160178
};
161179

180+
/**
181+
* Attempts to sync the object specified by `id` using whatever data
182+
* is locally stored for the object
183+
*
184+
* @param {String} id - object to sync
185+
* @param {Function} [callback] - optional callback
186+
* @returns {Promise<Object>} - object id, data
187+
*/
162188
Bucket.prototype.touch = function( id, callback ) {
163189
const task = this.storeAPI.get( id )
164190
.then( object => this.update( object.id, object.data ) );
165191

166192
return deprecateCallback( callback, task );
167193
};
168194

195+
/**
196+
* Deletes the object from the bucket
197+
*
198+
* @param {String} id - object to delete
199+
* @param {Function} [callback] - optional callback
200+
* @returns {Promise<Void>} - resolves when object has been deleted
201+
*/
169202
Bucket.prototype.remove = function( id, callback ) {
170203
const task = this.storeAPI.remove( id )
171204
.then( ( result ) => {
@@ -180,6 +213,13 @@ Bucket.prototype.find = function( query, callback ) {
180213
return deprecateCallback( callback, this.storeAPI.find( query ) );
181214
};
182215

216+
/**
217+
* Gets all known past versions of an object
218+
*
219+
* @param {String} id - object to fetch revisions for
220+
* @param {Function} [callback] - optional callback
221+
* @returns {Promise<Array<Object>>} - list of objects with id, data and version
222+
*/
183223
Bucket.prototype.getRevisions = function( id, callback ) {
184224
return deprecateCallback( callback, this.channel.getRevisions( id ) );
185225
}

0 commit comments

Comments
 (0)