| 1 | test("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 | |
| 17 | import assert from "node:assert/strict"; |
| 18 | import { test } from "vitest"; |
| 19 | import { Events } from "./Events.ts"; |