Evt.newCtx<T>()

Get a new instance of Ctx

The recommended way to get a new Ctx instance. The type argument is optional, default is void.

Returns

  • Ctx<T> if a type argument was specified

  • VoidCtx if no type argument was speficied.

Example

import { Evt } from "evt";

const ctx = Evt.newCtx();

ctx.getPrDone().then(()=> console.log("DONE"));

ctx.done(); //Prints "DONE"

//----------------------------

const ctxData = Evt.newCtx<Uint8Array>();

ctxText.getPrDone().then(
    data=> console.log(`DONE: ${data.byteLength} bytes`)
);

ctxText.done(new Uint8Array([1,2,3])); //Prints "DONE: 3 bytes"

****Run the example****

Last updated