Skip to content

0.1.0

Latest

Choose a tag to compare

@Janlaywss Janlaywss released this 24 Mar 08:05

🥳 feat: add cleanup effect api, Used to clean up the side effects of running tasks

const runner = new TaskRunner<Task>(({task}) => {
    let timeRef: TimeRef = {value: undefined};
    const cleanup = () => {
        clearTimeout(timeRef.value);
    }
    const handle = async () => {
        const event = task.event;
        if (event === 'timeout') {
            return await timeoutTask(timeRef);
        }
    }
    return {handle, cleanup}
}, {
    concurrentExecuteTaskMax: 5,
    timeout: 5,
});