@esfx/async-manualresetevent Package

    The @esfx/async-manualresetevent package provides the AsyncManualResetEvent class, an async coordination primitive.

    Installation

    npm i @esfx/async-manualresetevent
    

    Usage

    • TypeScript
    • JavaScript (CommonJS)
    import { AsyncManualResetEvent } from "@esfx/async-manualresetevent";
    
    const event = new AsyncManualResetEvent();
    
    async function doSomeActivity() {
        // do some work asynchronously...
    
        // signal completion of the activity
        event.set();
    }
    
    async function doSomeOtherActivity() {
        // do some work asynchronously...
    
        // wait for 'doSomeActivity' to finish
        await event.wait();
    
        // keep working now that both activities have synchronized...
    }
    
    // start some work
    doSomeActivity();
    
    // start some other work
    doSomeOtherActivity();
    
    const { AsyncManualResetEvent } = require("@esfx/async-manualresetevent");
    
    const event = new AsyncManualResetEvent();
    
    async function doSomeActivity() {
        // do some work asynchronously...
    
        // signal completion of the activity
        event.set();
    }
    
    async function doSomeOtherActivity() {
        // do some work asynchronously...
    
        // wait for 'doSomeActivity' to finish
        await event.wait();
    
        // keep working now that both activities have synchronized...
    }
    
    // start some work
    doSomeActivity();
    
    // start some other work
    doSomeOtherActivity();
    

    Classes

    AsyncManualResetEvent

    Asynchronously notifies one or more waiting Promises that an event has occurred.

    • Improve this Doc
    Generated by DocFX