Pipe uses default offset and limit so no need to define those, just tell it that it's paged via headers.
var pagedPipe = AeroGear.Pipeline({
name: "cars",
settings: {
paged: "headers"
}
}).pipes.cars;
We could either do a read() or next() as next() would determine that there isn't a current page and get the first page.
pagedPipe.next({
success: function( data ) {
// do something
},
error: function() {
// handle it
}
});
// Get the second page
pagedPipe.next({
success: function( data ) {
// do something
},
error: function() {
// handle it
}
});
// Back to first page
pagedPipe.prev({
success: function( data ) {
// do something
},
error: function() {
// handle it
}
});
Now we want 10 per page and to start on page 3
pagedPipe.updatePageConfig({
offset: 2,
limit: 10
});
Now next() will get the second 10 items. Then we could go as far to even say we don't want it paged anymore:
pagedPipe.updatePageConfig({
paged: false
});
Now next() or read() return all items from the endpoint.