pinia-plugin-yjs
v0.0.4
Published
pinia plugin that enables sharing of state between clients via Yjs
Downloads
12
Maintainers
Readme
pinia-plugin-yjs
Example
import { createPinia } from 'pinia'
import * as Y from 'yjs'
import { WebrtcProvider } from 'y-webrtc'
import { createPiniaYJSPlugin } from 'pinia-plugin-yjs'
const ydoc = new Y.Doc()
const webrtcProvider = new WebrtcProvider('roomName', ydoc, { signaling: ['ws://localhost:4444'] })
const pinia = createPinia()
pinia.use(createPiniaYJSPlugin({ doc: ydoc }))
defineStore('todo', () => {
// xxx
return {
// ...
}
}, {
// enable sharing
sharing: true,
})