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

Zero does not get synced #6

Open
Spica2 opened this issue Mar 21, 2020 · 2 comments
Open

Zero does not get synced #6

Spica2 opened this issue Mar 21, 2020 · 2 comments

Comments

@Spica2
Copy link

Spica2 commented Mar 21, 2020

When I define
export const count = syncable('count', 2, false);
an then change the store to 0 I do get 2 back, when I read the store again. Maybe all localstores should be strings? How to deal with that.

@Spica2
Copy link
Author

Spica2 commented Mar 21, 2020

Just tried
export const count = writable( localStorage.getItem("count") || 4 );
count.subscribe(val => localStorage.setItem("count", val ));
and was fine
edit: but only in browser in dev mode. With capacitor on android app freezes an seem not beeing able to load count

@Spica2
Copy link
Author

Spica2 commented Jul 2, 2020

If you want to sync also values explicitely set to 0 change line 36 of index.js to
lastValue = ( get(key) === "" )? value : get(key);
The condition referes to line 8-10.

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