Skip to content

oguz-yilmaz/taskchain

Repository files navigation

taskchain

Installation

npm install @o.yilmaz/taskchain

Creating Tasks

import { AbstractTask } from '@o.yilmaz/taskchain'

export class Task1 extends AbstractTask {
	isRun = false

	// determines if this task's run method will be called
	shouldRun(parameters): boolean {
		return true
	}

	run(parameters) {
		this.isRun = true

		return {
			run: true
		}
	}
}

Processing Tasks

The TaskChain constructor will take object parameter which in turn
will be passed to each task's shouldRun and run methods.

const task1 = new Task1()
const task2 = new Task2()
const task3 = new Task3()

// the parameters will be passed to 
// each task's `shouldRun` and `run` methods
const chain = new TaskChain({
	param1: true,
	param2: 'test'
})

chain
	.registerTask(task1)
	.registerTask(task2)
	.registerTask(task3)
	.processChain()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published