Skip to content

Instantly share code, notes, and snippets.

@imownbey
Created May 23, 2013 20:05
Show Gist options
  • Save imownbey/5639005 to your computer and use it in GitHub Desktop.
Save imownbey/5639005 to your computer and use it in GitHub Desktop.
var a = null;
var promise = somethingLongTahtReturnsAPromise();
function chainToAndSet(promise) {
promise.then(function(values) { a = values })
return promise;
}
function sort() {
new Promise(function(values) { _.sort(values) }
}
chainToAndSet(promise).then(sort()); // a will not be sorted
// -----------------
// What you want to be able to do
promise.then(function(values) { values[0..10] }).then(sort());
// And in your view just say
{{promise.value}}
// Which will fill in once the promise is fulfilled, and you dont care what is in the chain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment