Created
August 15, 2015 00:21
-
-
Save shaoshing/80520a62df5ecb6b56f9 to your computer and use it in GitHub Desktop.
superselect.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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