surrealdb / indxdb

A key-value database engine abstraction layer for IndexedDB in WASM
https://crates.io/crates/indxdb
Apache License 2.0
89 stars 7 forks source link

Run indxdb in a WebWorker #3

Open dskvr opened 2 days ago

dskvr commented 2 days ago

SurrealDB solves a lot of frontend issues with me, primarily utilizing IndexedDB as a persistence layer while having a memory first approach. However, the one issue that does not seem to be addressed is moving the IndexedDB processing off of the main thread, while keeping the Surreal interface in the main thread (in my case while using @surrealdb/wasm)

Is this presently possible, and if not, are there any plans for implementation flexiblity with regards to threads in Surreal 2.0?

nickchomey commented 2 days ago

I don't think this is something that surreal needs to handle. Rather, it would happen in your application code - instantiate a web worker and put surrealdb.wasm there.

I noticed yesterday that surrealist.app uses the partytown js library, which helps with moving things off the main thread. So perhaps that's a good place to start looking?

https://partytown.builder.io/

And an article about wasm in web workers. https://www.sitepen.com/blog/using-webassembly-with-web-workers