Closed floer32 closed 2 years ago
(I did try it and I couldn't get it working. So I'm wondering if there's just a known-good way, rather than the trial-and-error I've been doing.)
Hi @hangtwenty.
Broadcastchannel (cross tabs) and WebRTC syncing can both be managed using y-webrtc.
I think it should be possible to disable the webrtc part in y-webrtc, and use only the broadcastchannel. Could you try to pass an empty array as signaling servers? e.g.:
new WebrtcProvider("roomname", doc, { signaling: [] })
(see https://github.com/yjs/y-webrtc/blob/c059b8679e72e4a2cd59189b022a25edbd07cbeb/src/y-webrtc.js#L545)
@YousefED I tried something similar:
const doc = getYjsValue(store);
export const webrtcProvider = new WebrtcProvider("syncedstore-todos", doc as any, {
signaling: [],
filterBcConns: false,
maxConns: Number.POSITIVE_INFINITY,
});
// @ts-ignore
const provider = new IndexeddbPersistence("syncedstore-todos", doc as any);
From the y-webrtc
README it seemed like this part is needed to fully disable WebRTC connections:
filterBcConns: false
But I was experiencing inconsistent behavior and some errors.
I'll try another troubleshooting session tonight, and report back.
I can't reproduce the issue now, for some reason. But it's working, so that's great!
Glad to hear!
It seems like it's possible to use SyncedStore in multiple tabs in a browser, just locally. Just BroadcastChannel and
y-indexeddb
, no signaling servers, and I don't think it would need any WebRTC activity.I can share some code I've tried but first I just wanted to ask the question... Is there an official way to use it purely locally?