BatChannel.js

May 6, 2014

BatChannel is a javascript utility that allows you to send and receive several ajax requests at once. It sits on top of jQuery's promise-based ajax structure, and fires a single ajax request every so often. So instead of structuing your client-server interaction like $.ajax('/api/getUsersAndFriends.json') or

Now you can structure your application in a sensible manner but also keep your ajax requests to a minimum.

Eventually the Channel will send a request to the server that looks like:

{
    data: [
        {
            url: "/api/getFriends.json"
        },
        {
            url: "/api/getUsers.json"
        }
    ]
}

Because of the promises that are attached to the items in data, the responses will get executed individually and in order that they were requested.

Full source: