Hey, hey! The question on SQLDelight. Is there any...
# multiplatform
a
Hey, hey! The question on SQLDelight. Is there any persistent implementation for wasm target? The default worker is based on SQL.js and that one is in-memory implemenation. How can I persist my data on page reload? https://sqldelight.github.io/sqldelight/latest/js_sqlite/sqljs_worker/
f
Yes, it’s working. It's just some extra configuration https://github.com/frankois944/KtorKMPFileCaching?tab=readme-ov-file
c
We ripped out the SqlDelight Wasm and broke out web to thin client, dunno if François fixes it, but the sqldelight web driver has a bunch of issues that require transactions to be rewritten to support coroutines context.
things would never load, transactions would never close, notifiy was never called, its a huge mess
f
@chrisjenx never tries so far to use SQLDelight on Wasm, my unit test passed 🙂 Currently, there are two solution to persist data • local storage with limited size • SqlJS but with issues ...
c
yeah sqljs is probably the bigger issue causer
It's fine, the assumption we made was that if the user is uing web they probably have a decent connection anyway as thats how current web works lol
It looks like rooms implemention for wasmjs/web is structured differently
I see commits to hit the wasm target and use localStorage/ospf
f
I guess it’s too early to use sql + wasm + kmp
c
yeah... as of KMP 1.10 the UI and interactions are good, nav works great, esp with decompose, just yeah interactions with js is still "rough"
a
I like sqlite as it's unified language across all the platforms. So far I see no issues with in-memory implementation except that my artwork urls are not persistent so I can't make use of Coil3 cache in wasm. Currently just for this reason I am using js bridge to localstorage
Copy code
<script>
        function jsLocalStorageGet(key) {
            return localStorage.getItem(key);
        }

        function jsLocalStorageSet(key, value) {
            localStorage.setItem(key, value);
        }

        console.log('[localStorage Bridge] Initialized');
    </script>
and it works fine. It would be just more convenient to have the same sqlight implementation across all desktop/ios/android/web platforms.
f
Yes, localstorage is the good one but very limited space compared to SQLite
y
I ran into the same issue, so I switched to using sqlitenow. Its WebAssembly and JavaScript support work well, and unlike SQLDelight or Room, it doesn't require any platform-specific setup and code.
f
Yes but this library support less target than sqdelight
y
Yes sqldelight has definitely more platforms and sql databases support
v
We're using sqldelight and custom webworker with wasm sqlite (opfs). I found reference implementation on github and reworked for us. I can share the code.
a
I would appreciate if you could share
y
Recently Room supports WebAssembly and JS, it's going to be my go ti choice for a local SQLite database
1
c
I saw that, but Room requires KSP, which is a blocker for me
Unless they added a compiler plugin?