ar-g
08/03/2023, 3:22 PMStorageSettings(
delegate = js("self.chrome.storage.local") as? Storage ?: js("self.localStorage") as? Storage ?: error("Could not create chrome.storage.local"),
)
but so far I get ERROR ReferenceError: Storage is not defined
, any recommendation what I might be doing wrong?Adam S
08/03/2023, 7:06 PMexternal val localStorage: Storage
Try taking a look at the Kotlin Wrappers project - it provides common implementations, including localStorage
https://github.com/JetBrains/kotlin-wrappers/blob/b3386a80419d76e48f1a35e5ff7afad746e91faf/kotlin-browser/src/jsMain/generated/web/storage/localStorage.val.kt#L3
I can't see an equivalent for chrome.storage.local
, but you can probably use Kotlin Wrappers for inspirationar-g
08/03/2023, 8:55 PMar-g
08/03/2023, 9:03 PMpublic external interface ChromeStorage {
fun set(items: dynamic): Promise<Unit>
fun get(key: String): Promise<dynamic>
fun remove(key: String): Promise<Unit>
fun clear(): Promise<Unit>
}