<div class="gmail_quote"><p style="margin-right:0px;margin-bottom:15px;margin-left:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px;margin-top:0px!important">Hi Summers,</p><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><a href="https://gist.github.com/4532661" target="_blank">https://gist.github.com/4532661</a><br>

    <br>
    That is a way to do paging which keeps Pipes immutable, uses
    readWithFilter, and doesn&#39;t impose any (for convenient definitions
    of any) bookkeeping on the developer.<br></div></blockquote><div><br></div><div><br></div><div><p style="margin-right:0px;margin-bottom:15px;margin-left:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px;margin-top:0px!important">
from your <a href="https://gist.github.com/4532661" style="color:rgb(65,131,196);text-decoration:initial">Andorid gist</a>:</p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
A) <em>Once the response has been received, the Pipe implementation will return a List of objects. If this List instance is passed to Pipe.getPageContext the appropriate PageContext will be returned</em></p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
Note: There is no &#39;return&#39; - the <code style="font-size:12px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin:0px 2px;padding:0px 5px;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;white-space:nowrap">readWithFilter</code> is <code style="font-size:12px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin:0px 2px;padding:0px 5px;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;white-space:nowrap">void</code>, instead a Callback is invoked (<code style="font-size:12px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin:0px 2px;padding:0px 5px;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;white-space:nowrap">onSuccess(list)</code>), see <a href="https://github.com/aerogear/aerogear-android/blob/master/src/org/jboss/aerogear/android/pipeline/Pipe.java" style="color:rgb(65,131,196);text-decoration:initial">Pipe.java</a></p>
<p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">B) <em>The developer will receive from readWithFilter() a List of object. If she passes this list into Pipe.getPageContext(List result) she will receive the PageContext associated with this result.</em></p>
<p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">Do you mean like:</p><div class="highlight" style="background-color:rgb(255,255,255);border:none;padding:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
<pre style="font-size:13px;line-height:19px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">
<span class="o" style="font-weight:bold">...</span>
<span class="n">myPipe</span><span class="o" style="font-weight:bold">.</span><span class="na" style="color:rgb(0,128,128)">readWithFilter</span><span class="o" style="font-weight:bold">(</span><span class="n">filter</span><span class="o" style="font-weight:bold">,</span> <span class="k" style="font-weight:bold">new</span> <span class="n">Callback</span><span class="o" style="font-weight:bold">&lt;</span><span class="n">List</span><span class="o" style="font-weight:bold">&lt;</span><span class="n">Data</span><span class="o" style="font-weight:bold">&gt;&gt;()</span> <span class="o" style="font-weight:bold">{</span>
    <span class="nd">@Override</span>
    <span class="kd" style="font-weight:bold">public</span> <span class="kt" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="nf" style="color:rgb(153,0,0);font-weight:bold">onSuccess</span><span class="o" style="font-weight:bold">(</span><span class="n">List</span><span class="o" style="font-weight:bold">&lt;</span><span class="n">Data</span><span class="o" style="font-weight:bold">&gt;</span> <span class="n">data</span><span class="o" style="font-weight:bold">)</span> <span class="o" style="font-weight:bold">{</span>

        <span class="c1" style="color:rgb(153,153,136);font-style:italic">// get the PageContext:</span>
    <span class="n">PageContext</span> <span class="n">ctx</span> <span class="o" style="font-weight:bold">=</span> <span class="n">myPipe</span><span class="o" style="font-weight:bold">.</span><span class="na" style="color:rgb(0,128,128)">getPageContext</span><span class="o" style="font-weight:bold">(</span><span class="n">data</span><span class="o" style="font-weight:bold">);</span>
        <span class="o" style="font-weight:bold">...</span>
    <span class="o" style="font-weight:bold">}</span>

    <span class="nd">@Override</span>
    <span class="kd" style="font-weight:bold">public</span> <span class="kt" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="nf" style="color:rgb(153,0,0);font-weight:bold">onFailure</span><span class="o" style="font-weight:bold">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o" style="font-weight:bold">)</span> <span class="o" style="font-weight:bold">{</span>
    <span class="o" style="font-weight:bold">}</span>
<span class="o" style="font-weight:bold">});</span>
</pre></div><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">Not sure about that.....</p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
But for iOS I am thinking about passing in the <code style="font-size:12px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin:0px 2px;padding:0px 5px;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;white-space:nowrap">PageContext</code> into the closure/block of the <code style="font-size:12px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin:0px 2px;padding:0px 5px;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;white-space:nowrap">readWithFilter</code>, like:</p>
<div class="highlight" style="background-color:rgb(255,255,255);border:none;padding:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px"><pre style="font-size:13px;line-height:19px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">
<span class="k" style="font-weight:bold">-</span><span class="p">(</span><span class="kt" style="color:rgb(68,85,136);font-weight:bold">void</span><span class="p">)</span> <span class="nf" style="color:rgb(153,0,0);font-weight:bold">readWithFilter:</span><span class="p">(</span><span class="kt" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="p">(</span><span class="o" style="font-weight:bold">^</span><span class="p">)(</span><span class="kt" style="color:rgb(68,85,136);font-weight:bold">id</span><span class="o" style="font-weight:bold">&lt;</span><span class="n">AGFilterConfig</span><span class="o" style="font-weight:bold">&gt;</span> <span class="n">config</span><span class="p">))</span> <span class="n">config</span>
               <span class="nl">success:</span><span class="p">(</span><span class="kt" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="p">(</span><span class="o" style="font-weight:bold">^</span><span class="p">)(</span><span class="kt" style="color:rgb(68,85,136);font-weight:bold">id</span> <span class="n">listOfObjects</span><span class="p">,</span> <span class="kt" style="color:rgb(68,85,136);font-weight:bold">id</span> <span class="n">pageContext</span><span class="p">))</span><span class="n">success</span>
               <span class="nl">failure:</span><span class="p">(</span><span class="kt" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="p">(</span><span class="o" style="font-weight:bold">^</span><span class="p">)(</span><span class="n">NSError</span> <span class="o" style="font-weight:bold">*</span><span class="n">error</span><span class="p">))</span><span class="n">failure</span><span class="p">;</span>
</pre></div><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">A usage would look like:</p><div class="highlight" style="background-color:rgb(255,255,255);border:none;padding:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
<pre style="font-size:13px;line-height:19px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">
    <span class="p">[</span><span class="n">pipe</span> <span class="nl">readWithFilter:</span><span class="o" style="font-weight:bold">^</span><span class="p">(</span><span class="kt" style="color:rgb(68,85,136);font-weight:bold">id</span><span class="o" style="font-weight:bold">&lt;</span><span class="n">AGFilterConfig</span><span class="o" style="font-weight:bold">&gt;</span> <span class="n">config</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1" style="color:rgb(153,153,136);font-style:italic">// set the filter args and override the given defaults</span>
    <span class="p">}</span> <span class="nl">success:</span><span class="o" style="font-weight:bold">^</span><span class="p">(</span><span class="kt" style="color:rgb(68,85,136);font-weight:bold">id</span> <span class="n">listOfObjects</span><span class="p">,</span> <span class="kt" style="color:rgb(68,85,136);font-weight:bold">id</span> <span class="n">pageContext</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1" style="color:rgb(153,153,136);font-style:italic">// work with the listOfObjects reponse.</span>
        <span class="c1" style="color:rgb(153,153,136);font-style:italic">// for paging/query info, access the given pagecontext,</span>
        <span class="c1" style="color:rgb(153,153,136);font-style:italic">// of the CURRENT request</span>
        <span class="p">...</span>
    <span class="p">}</span> <span class="nl">failure:</span><span class="o" style="font-weight:bold">^</span><span class="p">(</span><span class="n">NSError</span> <span class="o" style="font-weight:bold">*</span><span class="n">error</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1" style="color:rgb(153,153,136);font-style:italic">// handle errorz</span>
    <span class="p">}];</span>
</pre></div><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">Any thoughts ?</p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
Not sure I like (or understand) the <code style="font-size:12px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin:0px 2px;padding:0px 5px;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;white-space:nowrap">Pipe.getPageContext(List result)</code> call. Current mindset is that the<code style="font-size:12px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin:0px 2px;padding:0px 5px;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;white-space:nowrap">PageContext</code> just (and <em>only</em>) belongs to the previous (executed) request... Not sure I want to support something like</p>
<div class="highlight" style="background-color:rgb(255,255,255);border:none;padding:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px"><pre style="font-size:13px;line-height:19px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">
<span class="c1" style="color:rgb(153,153,136);font-style:italic">// first call:</span>
<span class="n">List</span><span class="o" style="font-weight:bold">&lt;</span><span class="n">SomeType</span><span class="o" style="font-weight:bold">&gt;</span> <span class="n">first</span><span class="o" style="font-weight:bold">;</span>
<span class="n">myPipe</span><span class="o" style="font-weight:bold">.</span><span class="na" style="color:rgb(0,128,128)">readWithFilter</span><span class="o" style="font-weight:bold">(.....)</span> <span class="c1" style="color:rgb(153,153,136);font-style:italic">// set first inside of callback</span>
<span class="o" style="font-weight:bold">...</span>
<span class="c1" style="color:rgb(153,153,136);font-style:italic">// second call:</span>
<span class="n">List</span><span class="o" style="font-weight:bold">&lt;</span><span class="n">SomeType</span><span class="o" style="font-weight:bold">&gt;</span> <span class="n">second</span><span class="o" style="font-weight:bold">;</span>
<span class="n">myPipe</span><span class="o" style="font-weight:bold">.</span><span class="na" style="color:rgb(0,128,128)">readWithFilter</span><span class="o" style="font-weight:bold">(.....)</span> <span class="c1" style="color:rgb(153,153,136);font-style:italic">// set second inside of callback</span>
<span class="o" style="font-weight:bold">...</span>
<span class="c1" style="color:rgb(153,153,136);font-style:italic">// third call:</span>
<span class="n">List</span><span class="o" style="font-weight:bold">&lt;</span><span class="n">SomeType</span><span class="o" style="font-weight:bold">&gt;</span> <span class="n">third</span><span class="o" style="font-weight:bold">;</span>
<span class="n">myPipe</span><span class="o" style="font-weight:bold">.</span><span class="na" style="color:rgb(0,128,128)">readWithFilter</span><span class="o" style="font-weight:bold">(.....)</span> <span class="c1" style="color:rgb(153,153,136);font-style:italic">// set third inside of callback</span>
<span class="o" style="font-weight:bold">...</span>


<span class="c1" style="color:rgb(153,153,136);font-style:italic">/// A BIT LATER ....:</span>
<span class="n">myPipe</span><span class="o" style="font-weight:bold">.</span><span class="na" style="color:rgb(0,128,128)">getPageContext</span><span class="o" style="font-weight:bold">(</span><span class="n">first</span><span class="o" style="font-weight:bold">);</span> 
</pre></div><p style="margin-top:15px;margin-right:0px;margin-left:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px;margin-bottom:0px!important">I am not sure if that (<code style="font-size:12px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin:0px 2px;padding:0px 5px;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;white-space:nowrap">myPipe.getPageContext(first);</code>) is really desired (or would even easily work, as it would need to store the &quot;metadata&quot;)..... </p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px;margin-bottom:0px!important"><br></p><p style="margin-top:15px;margin-right:0px;margin-left:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px;margin-bottom:0px!important">
<br></p><p style="margin-top:15px;margin-right:0px;margin-left:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px;margin-bottom:0px!important">Perhaps I am just wrong.</p></div><div>
<br></div><div><br></div></div>-- <br>Matthias Wessendorf <br><br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>
twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a>