1.0.0 • Published 4 years ago

async-typescript-wrapper v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Async.js Typescript Wrapper

This repository is an extension of AsyncJS and requires it as a peer dependency. This package extends the functionality to work well with TypeScript and allows a more readable / approachable method to working with Async.

Usage

Extend the BaseAsyncJob in your classes to utilize the library. Call appendJobStep on each function you want to add to the call stack.

import { BaseAsyncJob, CallbackDelegate } from 'async-typescript-wrapper';

class HelloWorldJob extends BaseAsyncJob {

    constructor() {
        this.initialize();
    }

    run(): Promise<any> {
        return this.performRun();
    }

    private initialize(): void {
        this.appendJobStep(this.logHello);
        this.appendJobStep(this.logWorld);
    }

    private logHello(callback: CallbackDelegate): void {
        console.log("Hello");
        callback();
    }

    private logWorld(callback: CallbackDelegate): void {
        console.log("World!");
        callback();
    }
}
1.0.0

4 years ago