Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/cygnusroboticus/concurrency-light

Lightweight concurrency management, heavily inspired by ember-concurrency.
https://github.com/cygnusroboticus/concurrency-light

concurrency

Last synced: about 2 months ago
JSON representation

Lightweight concurrency management, heavily inspired by ember-concurrency.

Awesome Lists containing this project

README

        

# concurrency-light

Lightweight concurrency management, heavily inspired by [ember-concurrency](https://github.com/machty/ember-concurrency).

## Installation

- `yarn add concurrency-light`
- `npm install --save concurrency-light`

## Usage

```typescript
import { task, TaskStrategy, timeout } from "concurrency-light";

class DocClass {
constructor() {
this.asyncSearch("pants");
this.asyncSearch.isRunning; // true
this.asyncSearch("skirts"); // restarted
}

@task({ strategy: TaskStrategy.Restart })
*asyncSearch(search: string) {
yield timeout(500);
yield fetch(`/api/search?filter[query]=${search}`);
}
}
```