Solid Tasks is a package for managing and controlling concurrent operations in Solid.js applications. It provides a simple API for controlling the execution of promises and events. With Solid Tasks, you can forget about manual cancellation, concurrency side-effects and make your app user proof.
npm install solid-tasks
- Solid.js v1.0.0 or higher
import { createJob, work } from "solid-tasks";
const saveDataJob = createJob(async (signal) => {
await work(signal, saveData)
console.log('Data saved');
}, { mode: "drop"});
saveDataJob.perform(); // Task1: Pending...
saveDataJob.perform(); // Task2: Aborted. Another task is pending.
import { createJob, work } from "solid-tasks";
const saveDataJob = createJob(async (signal) => {
await work(signal, saveData)
console.log('Data saved');
}, { mode: "restart"});
saveDataJob.perform(); // Task1: Pending...
saveDataJob.perform(); // Task2: Aborting Task1. Pending...