Skip to content

Manage and control concurrent and async operations in Solid.js apps. Forget about manual cancellation, concurrency side-effects and make your app user proof.

License

Notifications You must be signed in to change notification settings

Exelord/solid-tasks

Repository files navigation

Solid Tasks logo

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...

About

Manage and control concurrent and async operations in Solid.js apps. Forget about manual cancellation, concurrency side-effects and make your app user proof.

Topics

Resources

License

Stars

Watchers

Forks