From 64523d8e81fb0c1afb625a6ed6d9b45daf7c367d Mon Sep 17 00:00:00 2001 From: David Khourshid Date: Tue, 24 Dec 2024 19:04:17 +0600 Subject: [PATCH] Add changeset --- .changeset/tasty-ravens-prove.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .changeset/tasty-ravens-prove.md diff --git a/.changeset/tasty-ravens-prove.md b/.changeset/tasty-ravens-prove.md new file mode 100644 index 0000000000..c3af9cdc6c --- /dev/null +++ b/.changeset/tasty-ravens-prove.md @@ -0,0 +1,16 @@ +--- +'@xstate/store': minor +--- + +The store now extends EventTarget, allowing for native DOM event handling capabilities while maintaining the existing `.on()` API. This change: + +- Adds support for standard `.addEventListener(…)` and `.removeEventListener(…)` methods +- Simplifies internal event handling by leveraging native `EventTarget` functionality +- Maintains full backwards compatibility with existing `.on(…)` method + +```ts +// ... +store.addEventListener('incremented', (event) => { + console.log(event.detail); +}); +```