Closed kjohnsen closed 1 year ago
Is it possible that you need a sync provider here? The minimal svelte example uses the WebRTC provider, this bit:
// Create a document that syncs automatically using Y-WebRTC
const doc = getYjsValue(store);
export const webrtcProvider = new WebrtcProvider("syncedstore-todos", doc);
from this example in the docs:
import { syncedStore, getYjsValue } from "@syncedstore/core";
import { WebrtcProvider } from "y-webrtc";
import { svelteSyncedStore } from "@syncedstore/svelte";
// Create your SyncedStore store
export const store = syncedStore({ todos: [], fragment: "xml" });
export const svelteStore = svelteSyncedStore(store);
// Create a document that syncs automatically using Y-WebRTC
const doc = getYjsValue(store);
export const webrtcProvider = new WebrtcProvider("syncedstore-todos", doc);
export const disconnect = () => webrtcProvider.disconnect();
export const connect = () => webrtcProvider.connect();
@kjohnsen have you tried the suggestion by @gleachkr ?
If it still doesn't work, could you provide a reproducible CodeSandbox or similar? For now, I'll mark the issue as closed
Maybe I'm missing something, but I tried to follow the examples and it's just not working. I tried a brand new Svelte kit app, installed dependencies, and set up a bare bones store
Then just
src/routes/+page.svelte
andsrc/lib/stores.js
as follows:The store is not kept up to date between tabs:![image](https://user-images.githubusercontent.com/19983357/185040937-30d5b6de-23cd-44f7-a6be-ae45532d2663.png)