Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

Awesome Lists containing this project

README

        


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

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