Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/kanziw/repeating-task-manager

Repeating task manager using tail recursion for Node.js
https://github.com/kanziw/repeating-task-manager

Last synced: about 2 months ago
JSON representation

Repeating task manager using tail recursion for Node.js

Awesome Lists containing this project

README

        

# RepeatingTaskManager
> Repeating task manager using tail recursion for Node.js

* [NPM repository](https://www.npmjs.com/package/repeating-task-manager)

## Install

### Using NPM
```bash
npm install repeating-task-manager
```

### Using Yarn
```bash
yarn add repeating-task-manager
```

## Usage

## Simple example
```javascript
import RepeatingTaskManager from 'repeating-task-manager'

const rtm = new RepeatingTaskManager()

const taskKey = 'TASK_KEY'
let cnt = 0
rtm.register(taskKey, 10, () => console.log(`[${++cnt}] TASK!`))

setTimeout(() => rtm.clear(taskKey), 1000)

// [1] TASK!
// [2] TASK!
// [3] TASK!
// [4] TASK!
// [5] TASK!
// [6] TASK!
// [7] TASK!
// [8] TASK!
// [9] TASK!
// [10] TASK!
// ....
```

## rtm.register
> Register task.
> Throws an Error when an already registered task key is entered.

### (taskId, interval, taskFunction[, options]) => void
* taskId `` Unique ID for task
* interval `` Interval times(ms) between before task and after task
* taskFunction: `` Function to be executed repeatedly
* options
* onError: ``
* err: ``

## rtm.execute
> Execute task function immediately

### (taskId[, options]) => void (or depends on task function.)
* taskId ``
* options
* isRegister `` Default: false, True only when registered.
* ...CUSTOM_PROPERTIES

## rtm.clear
> Clear(remove) task.

### (taskId) => void
* taskId ``

## rtm.clearAll
> Clear(remove) all tasks.

### () => void

## rtm.pause
> Pause all tasks without param.
> Pause task with taskId.

### ([taskId]) => void

## rtm.resume
> Resume all tasks without param.
> Resume task with taskId.

### ([taskId]) => void