var reqcb = (function() {
    var jumlahSelesai, reqSelesai, callBacks, singleCallBack;

    return function(options) {
        if (!options) options = {};

        jumlahSelesai = options.jumlahReq || 0;
        reqSelesai = options.reqSelesai || 0;
        callBacks = [];
        var fireCallbacks = function() {
            //console.log("we're all complete");
            for (var i = 0; i < callBacks.length; i++) callBacks[i]();
        };
        if (options.singleCallback) callBacks.push(options.singleCallback);

        this.addCallbackToQueue = function(isComplete, callback) {
            if (isComplete) reqSelesai++;
            if (callback) callBacks.push(callback);
            if (reqSelesai == jumlahSelesai) fireCallbacks();
        };
        this.requestComplete = function(isComplete) {
            if (isComplete) reqSelesai++;
            if (reqSelesai == jumlahSelesai) fireCallbacks();
        };
        this.setCallback = function(callback) {
            callBacks.push(callBack);
        };
    };
})();