svelte-syncable icon indicating copy to clipboard operation
svelte-syncable copied to clipboard

Zero does not get synced

Open Spica2 opened this issue 4 years ago • 2 comments

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 avatar Mar 21 '20 16:03 Spica2

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 avatar Mar 21 '20 17:03 Spica2

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.

Spica2 avatar Jul 02 '20 14:07 Spica2