Looking to use 2.1.0 (and in particular it's Wasm ...
# squarelibraries
j
Looking to use 2.1.0 (and in particular it's Wasm support) in PeopleInSpace sample (hacked together so far in following branch https://github.com/joreilly/PeopleInSpace/tree/sql_delight_wasm) but running in to following....is there some additional hook etc needed to ensure tables are created?
Copy code
WebWorkerException: {"message":"no such table: People","name":"Error"}
I'm now using
generateAsync = true
(as seems to be needed now) so perhaps something related to that
c
Same issue for me also.
j
I also tried explicitly calling
create
(which I just remembered had to be done for JVM target as well) but getting same error
Copy code
val driver = createDefaultWebWorkerDriver()
            .also { PeopleInSpaceDatabase.Schema.create(it) }
c
Me too.
j
ok, turns out we need to call
awaitCreate
....hacked it here and it worked......need to figure out now how to tie it in to Koin setup (has to be called from coroutine
c
Copy code
GlobalScope.launch(Dispatchers.Default) {
    Database.Schema.awaitCreate(it)
}
For me it works, but still not a good approach.
d
In JS and Wasm the actual SQLite runtime is all taking place asynchronously on a separate thread (a Web Worker) so all calls need to be awaited to ensure that the work is completed before continuing
👍 1