-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full offline mode (createSubscribeQuery) #575
Comments
If you want full offline support, including queries (which are usually handled by the DB, so not very offline-friendly!), then I have wondered in the past about running an instance of the ShareDB server in the browser (since it is, after all, JavaScript). It would have query support thanks to The tricky part is that you'd still need to figure out how to sync your in-memory DB state with indexdb, which isn't a solved problem as far as ShareDB goes, and I sadly don't have any time to work on that personally. |
Hmm, interested. I'm keen to spend time figuring it out. Could elaborate how I'd "mock" the results coming through on connection from indexDB (as opposed to remotely)? Where is a good starting point? I looked into custom middleware (db adapter) but I'm unclear where to "inject" it
|
You could probably start by just copy-pasting and/or forking You'd register it on your "backend" (which is actually running on the server) like any other DB adapter. I forgot to mention that if you get this working fully offline, there's still some work to do once you come back online to reconcile your local database with the real database, since your document histories will have diverged. I haven't thought too hard on that yet, but I guess we can cross that bridge once you get your local DB running properly 😅 |
Thanks- I'm a little confused how I'd run it on the 'backend' though- this would have to be client side (browser) offline mode. Did you mean to run the server code in my browser (somehow connecting a socket to it)?
|
FWIW, I made an alternate approach too, which was to re-created the
|
Yes, this is exactly what I mean. If you run the server code in your browser, out-of-the-box you can already call |
I don't think you want |
I tried installing Hmm seems it's still using stream, no? Eg here: Line 2 in e29936c
|
Yes, you'll need to include this in whatever you're using to package your JS. For example, if using Webpack 5: https://webpack.js.org/configuration/resolve/#resolvefallback |
Hmm I'm using plain js (no bundler), i can't figure it out I thought exports would do it in package.json |
Unfortunately you currently need some sort of bundler for ShareDB. See #255 |
As an alternative, can you offer any suggestion on the below example? It work well, except the Is there another event I need to emit other than 'submitOp'? Is there some "special" way the Doc is updated?
|
Hi,
I’m trying to create a fully offline experience, not only storing the ops to send- but reading data from local storage (indexdb) when there’s no connection to the server.
My guess is something like:
{
data,
src: connection.id,
v: version,
seq: connection.seq,
c: collection,
d: id,
}
Is this plausible- can i simply recreate each “doc”?
Do you have any suggestion on implementation?
The text was updated successfully, but these errors were encountered: