Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate all Local Storage into a static utility object somewhere. #3

Open
aarontabor opened this issue Jul 16, 2020 · 0 comments
Open

Comments

@aarontabor
Copy link
Contributor

aarontabor commented Jul 16, 2020

Problem

Player saved data including stats and saved paintings are currently saved using Window.localStorage.

Currently, the API calls to set and retrieve these saved items are scattered throughout the code base. This is really problematic because it litters implicit assumptions about the structure of these saved objects throughout the entire project - which is inevitably going to come back to bite us long-term.

Possible Solution

Ideally, it would be awesome to extract and encapsulate all of the Window.localStorage related source code into a single utility, which would not only simplify the code base overall, but would make it easy to move to another form of storage in the future.

Current Blocker

I've taken a couple attempts at this so far, and don't really like how any of them have turned out yet. For example, I'd like it to work consistently with caller expectations, but having trouble with calls such as...

// this would be ideal
let painting = Painting.create();
DataStore.paintings.push(painting)

... which would be much less error prone for callers than having to explictly use the DataStore's setter:

// this is as close as I'm getting
let painting = Painting.create();
DataStore.paintings = DataStore.paintings.push(painting);

Anyway, leave this alone for now and think about it a little more...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant