EVT
Search…
evt.evt[Attach|Detach]
evt.evtAttach and evt.evtDetach are accessors for Evt<Handler<T, any>> that posts every time a new handler is attached to/detached from the Evt<T>.
1
import { Evt } from "evt";
2
3
const evtText= new Evt<string>();
4
5
function myCallback(text: string){};
6
7
evtText.getEvtAttach().attach(
8
handler=> console.log(`${handler.callback.name} attached`)
9
);
10
11
evtText.getEvtDetach().attach(
12
handler=> console.log(`${handler.callback.name} detached`)
13
);
14
15
//"myCallback attached" is printed to the console.
16
evtText.attach(callback);
17
18
//"myCallback detached" is printed to the console.
19
evtText.detach();
Copied!
Last modified 1yr ago
Copy link