relay-link-batch
Version:
Relay Link that performs batching and operation on batched Operations
32 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BatchLink = void 0;
var tslib_1 = require("tslib");
var relay_link_1 = require("relay-link");
var batching_1 = require("./batching");
var batching_2 = require("./batching");
Object.defineProperty(exports, "OperationBatcher", { enumerable: true, get: function () { return batching_2.OperationBatcher; } });
var BatchLink = (function (_super) {
tslib_1.__extends(BatchLink, _super);
function BatchLink(options) {
var _a;
var _this = _super.call(this) || this;
var _b = options.batchInterval, batchInterval = _b === void 0 ? 10 : _b, _c = options.batchMax, batchMax = _c === void 0 ? 0 : _c, batchHandler = options.batchHandler, _d = options.batchKey, batchKey = _d === void 0 ? function () { return ''; } : _d;
_this.batcher = new batching_1.OperationBatcher({
batchInterval: batchInterval,
batchMax: batchMax,
batchHandler: batchHandler,
batchKey: batchKey,
});
if (((_a = options.batchHandler) === null || _a === void 0 ? void 0 : _a.length) <= 1) {
_this.request = function (operation) { return _this.batcher.enqueueRequest({ operation: operation }); };
}
return _this;
}
BatchLink.prototype.request = function (operation, forward) {
return this.batcher.enqueueRequest({ operation: operation, forward: forward });
};
return BatchLink;
}(relay_link_1.RelayLink));
exports.BatchLink = BatchLink;
//# sourceMappingURL=batchLink.js.map