hubber-memory-game icon indicating copy to clipboard operation
hubber-memory-game copied to clipboard

Save the hubbers in localstorage

Open IonicaBizau opened this issue 10 years ago • 3 comments

We're now making API requests to GitHub API: max 60 requests / hour. A nice improvement would be to store the hubbers list in browser's localStorage and try to update it every time (just in case new hubbers are appearing).

  1. Check if the localStorage contains hubbers
  2. Try to update the localStorage info.
  3. If 1 and 2 failed, take the hubbers from our file.

:dizzy:

IonicaBizau avatar Oct 10 '15 17:10 IonicaBizau

@IonicaBizau oh interesting, I've never heard of localStorage before.

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

alysonla avatar Nov 11 '15 02:11 alysonla

@alysonla Yep, it's a nice browser feature. :sparkle:

IonicaBizau avatar Nov 11 '15 05:11 IonicaBizau

Basically you can do something like:

// To set the data
localStorage.setItem("hubbers", JSON.stringify([/* wonderful people */]);

// To get the data
JSON.parse(localStorage.getItem("hubbers"));

IonicaBizau avatar Nov 11 '15 05:11 IonicaBizau