gitter-realtime-client
Advanced tools
Comparing version 0.3.5 to 0.3.6
"use strict"; | ||
var _ = require('underscore'); | ||
var Backbone = require('backbone'); | ||
var backboneUrlResolver = require('backbone-url-resolver'); | ||
var defaultContextModel = require('./default-context-model'); | ||
var debug = require('debug-proxy')('gtc:live-collection'); | ||
var _ = require('underscore'); | ||
var Backbone = require('backbone'); | ||
var backboneUrlResolver = require('backbone-url-resolver'); | ||
var defaultContextModel = require('./default-context-model'); | ||
var debug = require('debug-proxy')('grc:live-collection'); | ||
var backboneStateTracking = require('./backbone-state-tracking'); | ||
@@ -13,2 +14,9 @@ var PATCH_TIMEOUT = 2000; // 2000ms before a patch gives up | ||
modelName: '', | ||
/** | ||
* Indicates that when a subscribe occurs, the server | ||
* will return a snapshot. Defaults to true, but can | ||
* also be a function returning true or false. | ||
* TODO: allow this to be passed in `options` | ||
*/ | ||
subscribeReturnsSnapshot: true, | ||
constructor: function(models, options) { | ||
@@ -32,11 +40,6 @@ var defaults = { snapshot: true }; | ||
this.urlModel = this._getUrlModel(); | ||
backboneStateTracking.track(this); | ||
this._loading = false; | ||
this.listenToOnce(this, 'sync', this._onInitialLoad); | ||
this.listenTo(this, 'sync', this._onSync); | ||
this.listenTo(this, 'request', this._onRequest); | ||
if(options && options.listen) { | ||
this.listen(options); | ||
this.listen(); | ||
} | ||
@@ -90,24 +93,3 @@ | ||
_onSync: function() { | ||
this._loadStateChange(false); | ||
}, | ||
_onRequest: function() { | ||
this._loadStateChange(true); | ||
}, | ||
_loadStateChange: function(newState) { | ||
newState = !!newState; | ||
var current = !!this._loading; | ||
this._loading = newState; | ||
if (newState !== current) { | ||
this.trigger('loadingStateChange', newState); | ||
} | ||
}, | ||
isLoading: function() { | ||
return this._loading; | ||
}, | ||
listen: function(/*options*/) { | ||
listen: function() { | ||
if (this.templateSubscription) throw new Error('Already subscribed'); | ||
@@ -124,6 +106,11 @@ | ||
debug('Resetting collection on resubscribe: %s', this.url()); | ||
this.reset(); | ||
this.trigger('request'); | ||
this.reset(); | ||
this._loadStateChange(true); | ||
var subscribeReturnsSnapshot = _.result(this, 'subscribeReturnsSnapshot'); | ||
if (subscribeReturnsSnapshot) { | ||
// Triggering a "request" will let listeners know that | ||
// data is being loaded and the collection is in a | ||
// loading state | ||
this.trigger('request'); | ||
} | ||
}); | ||
@@ -134,3 +121,2 @@ | ||
this.reset(); | ||
this._loadStateChange(true); | ||
}); | ||
@@ -137,0 +123,0 @@ }, |
"use strict"; | ||
var Faye = require('gitter-faye'); | ||
var log = require('loglevel'); | ||
var _ = require('underscore'); | ||
var Backbone = require('backbone'); | ||
var Faye = require('gitter-faye'); | ||
var log = require('loglevel'); | ||
var _ = require('underscore'); | ||
var Backbone = require('backbone'); | ||
var TemplateSubscription = require('./template-subscription'); | ||
var fayeDebug = require('debug-proxy')('gtc:faye'); | ||
var debug = require('debug-proxy')('gtc:client'); | ||
var fayeDebug = require('debug-proxy')('grc:faye'); | ||
var debug = require('debug-proxy')('grc:client'); | ||
@@ -11,0 +11,0 @@ /* @const */ |
"use strict"; | ||
var LiveCollection = require('./live-collection'); | ||
var RoomModel = require('./room-model'); | ||
var RoomModel = require('./room-model'); | ||
@@ -6,0 +6,0 @@ module.exports = LiveCollection.extend({ |
'use strict'; | ||
var backboneUrlResolver = require('backbone-url-resolver'); | ||
var log = require('loglevel'); | ||
var _ = require('underscore'); | ||
var Backbone = require('backbone'); | ||
var log = require('loglevel'); | ||
var _ = require('underscore'); | ||
var Backbone = require('backbone'); | ||
var defaultContextModel = require('./default-context-model'); | ||
@@ -8,0 +8,0 @@ |
{ | ||
"name": "gitter-realtime-client", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "Gitter Realtime Client", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61963
21
1502