AnsonH / plinko-game

A Plinko game built with Svelte
https://plinko-web-game.netlify.app/
15 stars 6 forks source link

perf: write balance to local storage on beforeunload #13

Closed AnsonH closed 2 months ago

AnsonH commented 2 months ago

Description

Ditches the use of svelte-persisted-store for the balance state, so that we writes the wallet balance value to local storage only on Window's beforeunload event instead of writing on every value change.

Motivation

While I'm trying to debug performance issues, I noticed that every dropBall call has an updateStorage call to update the local storage. While this occupies a small amount of time, my computer has a fast SSD so writing to disk is fast. The same cannot be said for low-end devices where I/O time is slow.

image

github-actions[bot] commented 2 months ago

Preview URL: https://66811097c64fcabc4e729bcf--plinko-web-game.netlify.app