Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

onSnapshotReceived modelled after onMongoConnect #16

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lerouxb
Copy link
Contributor

@lerouxb lerouxb commented Jun 14, 2016

liveCollection.onSnapshotReceived()
  .then(function() {
    // liveCollection has now been initialised. Do whatever.
  });

} else {
debug('Awaiting snapshot');
return new Promise(function(resolve) {
this.once('snapshot', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unbound here

Copy link
Contributor Author

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) {
Copy link
Member

@suprememoocow suprememoocow Jun 14, 2016

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() {
Copy link
Member

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reject(err)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants