Files
discord-decomp/modules/gateway/ActionBatcher.tsx
T
2026-11-01 12:12:55 +02:00

34 lines
860 B
TypeScript

// Metro module 12707 (f12708).
import Dispatcher from "../../Dispatcher";
class ActionBatcher {
static batchers = [];
constructor(a0, c19988_0, a2) {
this.action = null;
this.socket = a0;
this.shouldFlush = a2;
this.add = (a0) => {
this.action = c19988_0(this.action, a0);
};
ActionBatcher.batchers.push(this);
}
static flush(a0, a1) {
for (const batcher of ActionBatcher.batchers) {
const r28 = batcher;
if (batcher.action != null && (a0 == null || r28.shouldFlush(a0, a1))) {
r28.flush();
}
}
}
flush() {
const action = this.action;
this.action = null;
if (action != null) {
Dispatcher.dispatch(action).catch((a0) => this.socket.resetSocketAndClearCacheOnError({
error: a0,
action: action.type
}));
}
}
}
export default ActionBatcher;