Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can achieve this with flatmap. The syntax in Java is sadly a bit clunky because of the anonymous interfaces (will get better with Java 8 and lambdas). <code>Promise&lt;T&gt;.flatMap</code> accepts a <code>Function&lt;T, Promise&lt;U&gt;&gt;</code> and will return a <code>Promise&lt;U&gt;</code>. This means you can nest flatMaps from all your three operations and collect them with a flatmap, like this:</p> <pre><code>final Promise&lt;String&gt; promise1 = Promise.pure("one"); final Promise&lt;String&gt; promise2 = Promise.pure("two"); final Promise&lt;String&gt; promise3 = Promise.pure("three"); Promise&lt;String&gt; allThreeCombined = promise1.flatMap(new Function&lt;String, Promise&lt;String&gt;&gt;() { @Override public Promise&lt;String&gt; apply(final String result1) throws Throwable { return promise2.flatMap(new Function&lt;String, Promise&lt;String&gt;&gt;() { @Override public Promise&lt;String&gt; apply(final String result2) throws Throwable { return promise3.map(new Function&lt;String, String&gt;() { @Override public String apply(String result3) throws Throwable { return result1 + result2 + result3; } }); } }); } }); </code></pre> <p>If there is no special meaning to each of the different things you are fetching - for example if they are to be treated as a list of values you can also use <code>Promise.sequence()</code> which accepts a list of <code>Promise&lt;T&gt;</code> and return a <code>Promise&lt;List&lt;T&gt;&gt;</code> so you can react on all values arriving. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload