From a1f98075e6a7589c54a1171afec9fe3758087224 Mon Sep 17 00:00:00 2001 From: sdegutis Date: Sat, 17 Aug 2024 08:58:54 -0500 Subject: [PATCH] More realistic events. --- site/samples/sample5.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/site/samples/sample5.tsx b/site/samples/sample5.tsx index b6fdf3e..a738af1 100644 --- a/site/samples/sample5.tsx +++ b/site/samples/sample5.tsx @@ -37,13 +37,13 @@ class List extends EventTarget { const item = new Item(this, text); this.items.push(item); this.ul.append(item.li); - this.dispatchEvent(new Event('change')); + this.dispatchEvent(new Event('item-added')); return item; } rem(item: Item) { this.items = this.items.filter(it => it !== item); - this.dispatchEvent(new Event('change')); + this.dispatchEvent(new Event('item-removed')); } clearDone() { @@ -59,7 +59,7 @@ class List extends EventTarget { } itemChanged() { - this.dispatchEvent(new Event('change')); + this.dispatchEvent(new Event('item-toggled')); } } @@ -105,7 +105,9 @@ function Counter({ list }: { list: List }) { }; updateText(); - list.addEventListener('change', updateText); + list.addEventListener('item-added', updateText); + list.addEventListener('item-removed', updateText); + list.addEventListener('item-toggled', updateText); return span; }