Skip to content

Commit

Permalink
Fix: Pass copy of storage to storage event, not reference
Browse files Browse the repository at this point in the history
  • Loading branch information
therealPaulPlay committed Jan 25, 2025
1 parent 36aa176 commit 1219f55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 });
}

/**
Expand Down

0 comments on commit 1219f55

Please sign in to comment.