1.0.0 • Published 11 months ago

smart-task v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

smart-task

introduction

A task queue that is simple and easy to use, use Typescript wirte, full encapsulation of tasks and task managers, so you can start, pause, resume and close them.

usage

import { CommonTaskImpl } from "./lifecycle/CommonTaskImpl";
import { TaskManager } from "./lifecycle/TaskManager";

const taskList: CommonTaskImpl[] = []

const task = new CommonTaskImpl(() => {
    console.log(1 + 1);
});

const task2 = new CommonTaskImpl(() => {
    console.log(1 + 2);
});

const task3 = new CommonTaskImpl(() => {
    console.log(1 + 3);
});


taskList.push(task)
taskList.push(task2)
taskList.push(task3)

const taskMsg = new TaskManager(taskList)

taskMsg.start()
taskMsg.pause()

setTimeout(() => {
    taskMsg.resume()
}, 3000);
1.0.0

11 months ago