https://github.com/cygnusroboticus/concurrency-light
Lightweight concurrency management, heavily inspired by ember-concurrency.
https://github.com/cygnusroboticus/concurrency-light
concurrency
Last synced: 4 months ago
JSON representation
Lightweight concurrency management, heavily inspired by ember-concurrency.
- Host: GitHub
- URL: https://github.com/cygnusroboticus/concurrency-light
- Owner: CygnusRoboticus
- License: mit
- Created: 2019-06-29T21:51:07.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T22:35:02.000Z (over 2 years ago)
- Last Synced: 2025-03-21T12:21:29.643Z (4 months ago)
- Topics: concurrency
- Language: TypeScript
- Homepage:
- Size: 880 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
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}`);
}
}
```