diff --git a/index.html b/index.html
index 68df279..3a30ef5 100644
--- a/index.html
+++ b/index.html
@@ -81,7 +81,7 @@
// outputs: "meep moop"
- No, this has nothing to do with playing audio.
+ No, this still has nothing to do with playing audio.
diff --git a/page/state.html b/page/state.html
index bf6c094..68cef17 100644
--- a/page/state.html
+++ b/page/state.html
@@ -8,7 +8,7 @@
Module Index
-listener.js
+state.js
import {State} from 'state.js'
diff --git a/state.js b/state.js
index ff7398a..3cdede4 100644
--- a/state.js
+++ b/state.js
@@ -25,6 +25,8 @@ export class State extends EventTarget {
this.addEventListener
+ // Try running a "Changed" method for every changed property
+ // Can be disabled to maybe squeeze out some performance
if (options.methods ?? true) {
this.addEventListener("change", ({changes}) => {
new Map(changes).forEach((value, prop) => {
@@ -34,9 +36,11 @@ export class State extends EventTarget {
}
}
+ // When you only need one value, you can skip the proxy.
set value(value) { this.proxy.value = value }
get value() { return this.proxy.value }
+ // Anounces that a prop has changed
emit(prop, value) {
if (this.#options.defer ?? true) {
if (!this.#queue) {
@@ -84,6 +88,7 @@ export class StoredState extends State {
this.emit(key, value)
}
+ // Listen for changes from other windows
addEventListener("storage", event => {
let prop = event.key
if (prop === this.#valueKey) prop = 'value'