@equinor/videx-map
Version:
Component for Pixi-overlay in Leaflet.
35 lines (34 loc) • 996 B
TypeScript
interface Config {
/** Total number of iterations. */
iterations: number;
/** Size of each individual batch. */
batchSize: number;
/** Function to call for each iteration. */
func: (i: number) => void;
/** Function to call after each batch. */
postFunc?: () => void;
/** Function to call after finishing loop. */
endFunc?: () => void;
}
/** Class for running non-blocking for loops. */
export default class AsyncLoop {
/** Dictionary with intervals */
timers: {
[key: string]: NodeJS.Timeout;
};
/**
* Start a new asynchronous loop.
* @param key Key of loop
* @param config Configurations for asynchronous loop.
* @param interval Configurations interval between batches
*/
Start(key: string, config: Config, interval?: number): void;
/**
* Stop a single loop
* @param key Key of loop
*/
Stop(key: string): void;
/** Stop all ongoing loops */
StopAll(): void;
}
export {};