evt.enableTrace(...)

If you need help to track down a bug, you can use enableTrace to log what's going on with an Evt. Use evt.disableTrace() to stop logging.

import { Evt } from "evt";

{
    const evtCircle = new Evt<Circle>();

    evtCircle.enableTrace({ "id": "evtCircle n°1" });

    evtCircle.post(circle1);

    evtCircle.attachOnce(circle => {});

    evtCircle.post(circle2);

}

console.log("\n");

//Optional arguments 
{

    const evtCircle = new Evt<Circle>();

    evtCircle.enableTrace({
        "id": "evtCircle n°2",
        "formatter": circle => `CIRCLE(${circle.radius})`,
        "log": (...args)=> console.log(...["[myPrefix]",...args]) 
        // ^Log function default console log
    );

    evtCircle.attach(
        ({ radius }) => radius > 15, 
        circle => {}
    );

    evtCircle.post(circle1);
    evtCircle.post(circle2);

}

This will print:

Run the example

Last updated