This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"errors": [ | |
{ | |
"message": "Assignment to constant variable.", | |
"locations": [ | |
{ | |
"line": 2, | |
"column": 3 | |
} | |
], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global localStorage */ | |
import { writable } from 'svelte/store' | |
const storage = typeof localStorage !== 'undefined' ? localStorage : { | |
removeItem: key => { if (storage[key]) { delete storage[key] } }, | |
} | |
/** | |
* Tracks storage both in `localStorage` and in svelte's `writable` stores | |
* Usage: `const name = storable('name', 'arxpoetica')` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getStorage, storageSync } from '$shared/state-utils.svelte'; | |
const SYNC_KEY = 'some_synced_var'; | |
class SomeSvelteClass { | |
some_synced_var = $state(getStorage(SYNC_KEY) || 'foo'); | |
constructor() { | |
storageSync(SYNC_KEY, () => this.some_synced_var); | |
} | |
} |
OlderNewer