mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-18 05:43:38 +00:00
26 lines
656 B
TypeScript
26 lines
656 B
TypeScript
export interface ConnectAutomationBatch {
|
|
controller: AbortController;
|
|
stopCurrentRun: (() => Promise<void>) | null;
|
|
}
|
|
|
|
export const createConnectAutomationBatch = (): ConnectAutomationBatch => ({
|
|
controller: new AbortController(),
|
|
stopCurrentRun: null,
|
|
});
|
|
|
|
export const trackConnectAutomationStop = (
|
|
batch: ConnectAutomationBatch,
|
|
stopCurrentRun: (() => Promise<void>) | null,
|
|
): void => {
|
|
batch.stopCurrentRun = stopCurrentRun;
|
|
};
|
|
|
|
export const cancelConnectAutomationBatch = async (
|
|
batch: ConnectAutomationBatch,
|
|
): Promise<void> => {
|
|
batch.controller.abort();
|
|
if (batch.stopCurrentRun) {
|
|
await batch.stopCurrentRun();
|
|
}
|
|
};
|