Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Below is a comparison of the method usage proposed by each lib for handling paged resources.

AG-Controller Pipe Setup

Android

iOS

JS

// Any items marked as "default" could be left out but included for illustration
var pipe = AeroGear.Pipeline({
    name: "aerogear",
    settings: {
        paging: {
            pagingLocation: "header", //default
            pagingType: "offset", //default
            locatorParam: "offset", //default
            locatorValue: 0,
            locatorIdentifier: "AG-Paging-Offset", //default
            countParam: "limit", //default
            countValue: 10,
            countIdentifier: "AG-Paging-Limit" //default
        }
    }
}).pipes.aerogear;

Server which uses headers with custom names

Android

iOS

JS

// Any items marked as "default" could be left out but included for illustration
var pipe = AeroGear.Pipeline({
    name: "customHeaders",
    settings: {
        paging: {
            pagingLocation: "header", //default
            pagingType: "offset", //default
            locatorParam: "offset", //default
            locatorValue: 0,
            locatorIdentifier: "AG-Paging-Offset-Custom",
            countParam: "limit", //default
            countValue: 10,
            countIdentifier: "AG-Paging-Limit-Custom"
        }
    }
}).pipes.customHeaders;

Server which uses query params with custom names

###Android

###iOS

###JS

// Any items marked as "default" could be left out but included for illustration
var pipe = AeroGear.Pipeline({
    name: "customParams",
    settings: {
        paging: {
            pagingLocation: "header", //default
            pagingType: "offset", //default
            locatorParam: "offset-custom",
            locatorValue: 0,
            locatorIdentifier: "AG-Paging-Offset", //default
            countParam: "limit-custom",
            countValue: 10,
            countIdentifier: "AG-Paging-Limit" //default
        }
    }
}).pipes.customParams;

Server which uses request body data with custom names

Android

iOS

JS

// Any items marked as "default" could be left out but included for illustration
var pipes = AeroGear.Pipeline({
    name: "contentBodyParams",
    settings: {
        paging: {
            pagingLocation: "content",
            pagingType: "page",
            locatorParam: "p",
            locatorValue: 1,
            locatorIdentifier: "page_num",
            countParam: "rpp",
            countValue: 10,
            countIdentifier: "results_per_page"
        }
    }
});

All four examples above in one shot

Android

iOS

JS

// Any items marked as "default" could be left out but included for illustration
var pipes = AeroGear.Pipeline([
    {
        name: "aerogear",
        settings: {
            paging: {
                pagingLocation: "header", //default
                pagingType: "offset", //default
                locatorParam: "offset", //default
                locatorValue: 0,
                locatorIdentifier: "AG-Paging-Offset", //default
                countParam: "limit", //default
                countValue: 10,
                countIdentifier: "AG-Paging-Limit" //default
            }
        }
    },
    {
        name: "customHeaders",
        settings: {
            paging: {
                pagingLocation: "header", //default
                pagingType: "offset", //default
                locatorParam: "offset", //default
                locatorValue: 0,
                locatorIdentifier: "AG-Paging-Offset-Custom",
                countParam: "limit", //default
                countValue: 10,
                countIdentifier: "AG-Paging-Limit-Custom"
            }
        }
    },
    {
        name: "customParams",
        settings: {
            paging: {
                pagingLocation: "header", //default
                pagingType: "offset", //default
                locatorParam: "offset-custom",
                locatorValue: 0,
                locatorIdentifier: "AG-Paging-Offset", //default
                countParam: "limit-custom",
                countValue: 10,
                countIdentifier: "AG-Paging-Limit" //default
            }
        }
    },
    {
        name: "contentBodyParams",
        settings: {
            paging: {
                pagingLocation: "content",
                pagingType: "page",
                locatorParam: "p",
                locatorValue: 1,
                locatorIdentifier: "page_num",
                countParam: "rpp",
                countValue: 10,
                countIdentifier: "results_per_page"
            }
        }
    }
]);

// And a cleaner version without defaults
var cleanPipes = AeroGear.Pipeline([
    {
        name: "aerogear",
        settings: {
            paging: {
                locatorValue: 0,
                countValue: 10
            }
        }
    },
    {
        name: "customHeaders",
        settings: {
            paging: {
                locatorValue: 0,
                locatorIdentifier: "AG-Paging-Offset-Custom",
                countValue: 10,
                countIdentifier: "AG-Paging-Limit-Custom"
            }
        }
    },
    {
        name: "customParams",
        settings: {
            paging: {
                locatorParam: "offset-custom",
                locatorValue: 0,
                countParam: "limit-custom",
                countValue: 10
            }
        }
    },
    {
        name: "contentBodyParams",
        settings: {
            paging: {
                pagingLocation: "content",
                pagingType: "page",
                locatorParam: "p",
                locatorValue: 1,
                locatorIdentifier: "page_num",
                countParam: "rpp",
                countValue: 10,
                countIdentifier: "results_per_page"
            }
        }
    }
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment