-
Notifications
You must be signed in to change notification settings - Fork 17
onSnapshotReceived modelled after onMongoConnect #16
base: master
Are you sure you want to change the base?
Conversation
lerouxb
commented
Jun 14, 2016
} else { | ||
debug('Awaiting snapshot'); | ||
return new Promise(function(resolve) { | ||
this.once('snapshot', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
is unbound here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damnit. Fixed.
this.trigger('sync'); | ||
this.trigger('snapshot'); | ||
}, | ||
|
||
onSnapshotReceived: function() { | ||
if (this.snapshotReceived) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation currently doesn't take into account the collection being reset after a Bayeux reset.
Putting a _snapshotReceived = false
on the first line of _resetOptional
(before the short-curcuit) is probably the best place to put this.
debug('Snapshot received'); | ||
resolve(); | ||
}); | ||
self.once('subscriptionError', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need to forward the event from the templateSubscription. Maybe a test would help?
}); | ||
self.once('error', function() { | ||
debug('Error received before promise could get resolved.'); | ||
reject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reject(err)