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

Missing saveStates #10

Open
cullenn opened this issue Jan 4, 2020 · 2 comments
Open

Missing saveStates #10

cullenn opened this issue Jan 4, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@cullenn
Copy link
Contributor

cullenn commented Jan 4, 2020

It's really easy to miss calls to saveState(). Is it worth revisiting proxies in order to hook one up to call saveState() every time state gets set and scrap all other calls to saveState()? Feels like it'd be a lot more intuitive to just assume it's being saved every time you set it unless there's a situation where you'd want to set it and not save right away that I'm not considering

const saveFramePos = ($element, name) => {
if (!$element) return;
$element.classList.add('js-ui-is-saving');
$element.addEventListener('mouseup', () => {
state.windowsPos[name] = $element.getAttribute('style');
});
};

@timebomb0
Copy link
Owner

Yeah, it's definitely a potential issue. I originally wanted to avoid this because calls to localStorage.set, or saving state, are a lot more negatively performance impacting than setting an object.

I could run a check every 5 seconds to see if the state has changed, and if it has, save it. Then we wouldn't have to worry about calling state. What do you think?

@cullenn
Copy link
Contributor Author

cullenn commented Jan 4, 2020

Oh that makes sense, I wasn't thinking a proxy's set: on state would be triggered too often but maybe I'm underestimating that lol, checking every 5 seconds would definitely work as a nice safety net

@timebomb0 timebomb0 added the enhancement New feature or request label Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants