svelte-syncable
svelte-syncable copied to clipboard
Zero does not get synced
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.
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
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.