[aerogear-dev] Client Paging Strawman

Matthias Wessendorf matzew at apache.org
Tue Jan 15 05:37:26 EST 2013


Hi Summers,


> https://gist.github.com/4532661
>
> That is a way to do paging which keeps Pipes immutable, uses
> readWithFilter, and doesn't impose any (for convenient definitions of any)
> bookkeeping on the developer.
>


from your Andorid gist <https://gist.github.com/4532661>:

A) *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*

Note: There is no 'return' - the readWithFilter is void, instead a Callback
is invoked (onSuccess(list)), see
Pipe.java<https://github.com/aerogear/aerogear-android/blob/master/src/org/jboss/aerogear/android/pipeline/Pipe.java>

B) *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.*

Do you mean like:

...myPipe.readWithFilter(filter, new Callback<List<Data>>() {
    @Override
    public void onSuccess(List<Data> data) {

        // get the PageContext:
    PageContext ctx = myPipe.getPageContext(data);
        ...
    }

    @Override
    public void onFailure(Exception e) {
    }});

Not sure about that.....

But for iOS I am thinking about passing in the PageContext into the
closure/block of the readWithFilter, like:

-(void) readWithFilter:(void (^)(id<AGFilterConfig> config)) config
               success:(void (^)(id listOfObjects, id pageContext))success
               failure:(void (^)(NSError *error))failure;

A usage would look like:

    [pipe readWithFilter:^(id<AGFilterConfig> config) {
        // set the filter args and override the given defaults
    } success:^(id listOfObjects, id pageContext) {
        // work with the listOfObjects reponse.
        // for paging/query info, access the given pagecontext,
        // of the CURRENT request
        ...
    } failure:^(NSError *error) {
        // handle errorz
    }];

Any thoughts ?

Not sure I like (or understand) the Pipe.getPageContext(List result) call.
Current mindset is that thePageContext just (and *only*) belongs to the
previous (executed) request... Not sure I want to support something like

// first call:List<SomeType> first;myPipe.readWithFilter(.....) // set
first inside of callback...// second call:List<SomeType>
second;myPipe.readWithFilter(.....) // set second inside of
callback...// third call:List<SomeType>
third;myPipe.readWithFilter(.....) // set third inside of callback...

/// A BIT LATER ....:myPipe.getPageContext(first);

I am not sure if that (myPipe.getPageContext(first);) is really desired (or
would even easily work, as it would need to store the "metadata").....



Perhaps I am just wrong.


-- 
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20130115/6b0c2271/attachment-0001.html 


More information about the aerogear-dev mailing list