EVT
Search…
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.
1
import { Evt } from "evt";
2
3
{
4
const evtCircle = new Evt<Circle>();
5
6
evtCircle.enableTrace({ "id": "evtCircle n°1" });
7
8
evtCircle.post(circle1);
9
10
evtCircle.attachOnce(circle => {});
11
12
evtCircle.post(circle2);
13
14
}
15
16
console.log("\n");
17
18
//Optional arguments
19
{
20
21
const evtCircle = new Evt<Circle>();
22
23
evtCircle.enableTrace({
24
"id": "evtCircle n°2",
25
"formatter": circle => `CIRCLE(${circle.radius})`,
26
"log": (...args)=> console.log(...["[myPrefix]",...args])
27
// ^Log function default console log
28
);
29
30
evtCircle.attach(
31
({ radius }) => radius > 15,
32
circle => {}
33
);
34
35
evtCircle.post(circle1);
36
evtCircle.post(circle2);
37
38
}
Copied!
This will print:
1
(evtCircle n°1) 0 handler, { "type": "CIRCLE", "radius": 12 }
2
(evtCircle n°1) 1 handler, { "type": "CIRCLE", "radius": 33 }
3
4
[myPrefix] (evtCircle n°2) 0 handler, CIRCLE(12)
5
[myPrefix] (evtCircle n°2) 1 handler, CIRCLE(33)
Copied!
Last modified 1yr ago
Copy link