Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/exelord/solid-tasks
Manage and control concurrent and async operations in Solid.js apps. Forget about manual cancellation, concurrency side-effects and make your app user proof.
https://github.com/exelord/solid-tasks
actions concurrency jobs soildjs tasks
Last synced: 26 days ago
JSON representation
Manage and control concurrent and async operations in Solid.js apps. Forget about manual cancellation, concurrency side-effects and make your app user proof.
- Host: GitHub
- URL: https://github.com/exelord/solid-tasks
- Owner: Exelord
- License: mit
- Created: 2022-10-22T10:05:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-05T11:44:21.000Z (about 1 year ago)
- Last Synced: 2024-10-03T09:17:29.801Z (about 1 month ago)
- Topics: actions, concurrency, jobs, soildjs, tasks
- Language: TypeScript
- Homepage:
- Size: 900 KB
- Stars: 24
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
```sh
npm install solid-tasks
```## Requirements
- Solid.js v1.0.0 or higher
## Demo
- [Codesandbox](https://codesandbox.io/p/sandbox/solid-tasks-rupp9f)
## How to use it?
## Drop mode
```tsx
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
```tsx
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...
```