1test("disposing a listener leaves the others", () => {
2 const events = new Events<{ ping: [] }>();
3 const calls: string[] = [];
4 const offA = events.on("ping", () => calls.push("a"));
5 events.on("ping", () => calls.push("b"));
6 const offAny = events.onAny(() => calls.push("any a"));
7 events.onAny(() => calls.push("any b"));
8
9 offA();
10 offA();
11 offAny();
12 offAny();
13 events.emit("ping");
14 assert.deepEqual(calls, ["b", "any b"]);
15});
16
17import assert from "node:assert/strict";
18import { test } from "vitest";
19import { Events } from "./Events.ts";