decord/alpha/source/modules/gateway/ActionBatcher.tsx

63 lines
1.7 KiB
TypeScript
Raw Permalink Normal View History

2026-10-13 12:43:34 +00:00
// Module ID: 14280
// Function ID: 14281
// Name: ActionBatcher
2026-10-03 08:58:59 +00:00
// Dependencies: [584, 2]
2026-07-20 16:05:17 +00:00
2026-10-13 12:43:34 +00:00
// Module 14280 (ActionBatcher)
2026-10-03 08:58:59 +00:00
import DispatcherDefault from "Dispatcher" /* 584 */;
import size from "module_2" /* 2 */;
2026-08-24 06:08:38 +00:00
2026-07-29 08:29:29 +00:00
class ActionBatcher {
2026-10-03 08:58:59 +00:00
constructor(socket, arg1, shouldFlush) {
let closure_0 = arg1;
const obj = Object.create(new.target.prototype);
2026-07-29 08:29:29 +00:00
obj.action = null;
2026-10-03 08:58:59 +00:00
obj.socket = socket;
obj.shouldFlush = shouldFlush;
2026-07-29 08:29:29 +00:00
obj.add = (arg0) => {
obj.action = closure_0(obj.action, arg0);
2026-07-20 16:05:17 +00:00
};
2026-10-03 08:58:59 +00:00
const batchers = ActionBatcher.batchers;
batchers.push(obj);
2026-07-29 08:29:29 +00:00
return obj;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
static flush(arg0, arg1) {
const iter = ActionBatcher.batchers[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let obj = nextResult;
let tmp2 = null != nextResult.action;
if (tmp2) {
let shouldFlushResult = null == arg0;
if (!shouldFlushResult) {
shouldFlushResult = obj.shouldFlush(arg0, arg1);
}
tmp2 = shouldFlushResult;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
if (tmp2) {
let flushResult = obj.flush();
}
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
flush() {
const self = this;
const action = this.action;
this.action = null;
if (null != action) {
let obj = DispatcherDefault;
const dispatchResult = obj.dispatch(action);
dispatchResult.catch((error) => {
const socket = self.socket;
const obj = { error, action: action.type };
return socket.resetSocketAndClearCacheOnError(obj);
});
}
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
}
const prototype = ActionBatcher.prototype;
2026-07-29 08:29:29 +00:00
ActionBatcher.batchers = [];
const result = size.fileFinishedImporting("modules/gateway/ActionBatcher.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default ActionBatcher;