I was working on a project that allowed users to pull document data from the server to a local document. But documents from different sources should be prohibited.
Just like in Git, you cannot pull a different git into another git repository(except you merge or force pull)
But in yjs, I saw no way to do it. GUID and clientID are inconsistent between each initiation
@Himself65 I generate a globally unique deviceId client-side on app startup and persist it to localStorage. Then I use that in the WebsocketProvider room name to ensure it only syncs data that belongs to that device.
let deviceId = localStorage.getItem(deviceId)
if (!deviceId) {
deviceId = nanoid()
localStorage.setItem(deviceId)
}
new WebsocketProvider('wss://server:8080', deviceId, ydoc)