Skip to content

Instantly share code, notes, and snippets.

@weefbellington
Created July 25, 2014 19:10
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 weefbellington/46e53cdb312d3a871ad3 to your computer and use it in GitHub Desktop.
Save weefbellington/46e53cdb312d3a871ad3 to your computer and use it in GitHub Desktop.
parallel promises example
Promise<ResponseTypeA> responseA;
Promise<ResponseTypeB> responseB;
p1.then(new PromiseAction<A>() {
public void call(A response) {
// do something with the response
}
});
p2.then(new PromiseAction<B>() {
public void call(B value) {
// do something with the response
}
});
p1.and(p2).then(new PromiseAction<A, B>) {
public void call(A responseA, B responseB) {
// compute something that needs both values
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment