From 1219f5555fe686086a267fb8ed8904eb54250c71 Mon Sep 17 00:00:00 2001 From: PaulPlay <80539587+therealPaulPlay@users.noreply.github.com> Date: Sat, 25 Jan 2025 21:25:14 +0100 Subject: [PATCH] Fix: Pass copy of storage to storage event, not reference --- package.json | 2 +- src/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6affec0..9e29eb3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "playpeerjs", - "version": "1.1.1", + "version": "1.1.2", "description": "WebRTC-based wrapper for creating robust peer-2-peer multiplayer systems with ease.", "type": "module", "main": "dist/playpeer.js", diff --git a/src/index.js b/src/index.js index 1beed50..fd82f87 100644 --- a/src/index.js +++ b/src/index.js @@ -343,7 +343,7 @@ export default class PlayPeer { switch (data.type) { case 'storage_sync': this.#storage = data.storage; - this.#triggerEvent("storageUpdate", this.#storage); + this.#triggerEvent("storageUpdate", { ...this.#storage }); break; case 'peer_list': this.#hostConnectionsIdArray = data.peers; @@ -406,7 +406,7 @@ export default class PlayPeer { */ #setStorageLocally(key, value) { this.#storage[key] = value; - this.#triggerEvent("storageUpdate", this.#storage); + this.#triggerEvent("storageUpdate", { ...this.#storage }); } /**