Skip to content

Instantly share code, notes, and snippets.

@shaoshing
Created August 15, 2015 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaoshing/80520a62df5ecb6b56f9 to your computer and use it in GitHub Desktop.
Save shaoshing/80520a62df5ecb6b56f9 to your computer and use it in GitHub Desktop.
superselect.js
var detectNewOpenDocument = function () {
return Promise.delay(50).bind(this)
.then(function () {
return documentActions._getDocumentByRef(documentLib.referenceBy.current);
})
.then(function (doc) {
var currentDocumentID = this.flux.store("application").getCurrentDocumentID();
if (doc.documentID === currentDocumentID) {
throw "Retry";
}
})
.catch(detectNewOpenDocument);
}.bind(this);
return detectNewOpenDocument()
.bind(this)
.timeout(1000, "Timeout on detecting new document")
.then(function () {
return this.transfer(documentActions.updateDocument);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment