solid-tasks
v0.2.0
Published
Manage and control concurrent and async operations in Solid.js apps. Forget about manual cancellation, concurrency side-effects and make your app user proof.
Downloads
9
Maintainers
Readme
Solid Tasks
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.
Installation
npm install solid-tasks
Requirements
- Solid.js v1.0.0 or higher
Demo
How to use it?
Drop mode
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.
Restart mode
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...