blob: 32c0f39d1274811a5a7e3f473f98d696ec899dc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/*
* The interface exposed by this class is designed to closely match the interface expected by
* the `EventLog` component, so that you can do this:
*
* let capture = $state(new EventCapture());
* const someEvent = capture.on('someEvent');
*
* // …
*
* <EventLog events={capture.events} clear={capture.clear.bind(capture)} />
*/
export default class EventCapture {
events = $state([]);
on(event) {
return (...args) => this.events.push({ event, args });
}
clear() {
this.events = [];
}
}
|