Skip to content

Commit

Permalink
Add basic readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Exelord committed Jan 28, 2023
1 parent fd638c5 commit 1b55ad6
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,45 @@

# Solid Tasks

Solid Tasks is a package for managing and controlling async operations in solid-js applications. It provides a simple API for controlling the execution of promises and their cancellation. With Solid Tasks, it is easy to build robust and performant solid-js applications, especially when it comes to handling data fetching, events, and user interactions.
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

To install Solid Tasks can use npm:

```sh
npm install solid-tasks
```

## Requirements

- Solid.js v1.0.0 or higher
- Environment that supports [AbortController API](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)

## What are solid-tasks?
## 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"});

It is a plugin for solid-js that allows you to manage async operations in your application. It provides a way to perform and cancel async operations, and observe their state. solid-tasks uses jobs to coordinate async operations. By creating a job and performing it, you can execute a task and handle its cancellation and coordination. Jobs can be created in different modes that allows to handle different use cases such as button clicks, data loading, live search fields or long-polling.
saveDataJob.perform(); // Task1: Pending...
saveDataJob.perform(); // Task2: Aborted. Another task is pending.
```

## Restart mode

## Jobs
```tsx
import { createJob, work } from "solid-tasks";

A job is a way to coordinate async operations in your application. It provides a way to perform and cancel async operations, and observe their state. With solid-tasks, you can create jobs that allow you to handle cancellation and coordination of async operations. For example, you can use a job to handle a button click and prevent unexpected events from clicking it multiple times.
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...
```

0 comments on commit 1b55ad6

Please sign in to comment.