Skip to content

Commit

Permalink
More realistic events.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 17, 2024
1 parent a37e4d2 commit a1f9807
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions site/samples/sample5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -59,7 +59,7 @@ class List extends EventTarget {
}

itemChanged() {
this.dispatchEvent(new Event('change'));
this.dispatchEvent(new Event('item-toggled'));
}

}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a1f9807

Please sign in to comment.