Created
May 23, 2013 20:05
-
-
Save imownbey/5639005 to your computer and use it in GitHub Desktop.
This file contains 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 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