Open dev-guy opened 10 months ago
The following branch works but you need to run the following first: PORT=4444 npx y-webrtc server.js
https://github.com/good-ware/svelte-kanban/tree/synced-store
Demo
One window is Chrome and the other is Safari.
https://github.com/V-Py/svelte-kanban/assets/12297328/e4c8b0ee-6128-4c9c-b3f6-6f439610da1a
It's a little quirky.
Close up of a move column bug. It only happens when moving a column to the left. Notice when you move a column to the left, an extra card shows up in the new right-most column at the bottom in the other browser/tab.
https://github.com/V-Py/svelte-kanban/assets/12297328/8b39766a-7348-41f7-9c35-a8ea0ffc25e0
The move column bug is fixed. The fix involved using different orders depending on which direction the column is moved.
I tried the following method when moving right, which is how it works without CRDT. However, it doesn't work with CRDT:
Goal
Share the same Kanban board across different browsers or browser tabs, potentially to multiple users over the Internet.
Scope
This effort will clear a path for CRDT support with
svelte-kanban.
CRDT features will not be added tosvelte-kanban
because they will require additional libraries and changes to the API. It will be fairly easy to add CRDT-based multiuser support tosvelte-kanban
without negatively impacting the user experience, performance, API, or code quality.CRDT support will be implemented in a fork using SyncedStore which integrates YJs and Svelte stores.
Changes Needed
SyncedStore
only manages non-array objects ({}
). Therefore,$columns
which is currently awritable( [ ] )
must be refactored as:writable( { columns: [ ] } )
.$columns
store with a shallow copy. CRDT supports manipulating arrays, e.g., push, pop, and assigning a value to an array index, butSyncedStore
doesn't allow$columns = [...newColumns]
since other users might also add a column at roughly the same time. Instead, do this:$columns = $columns
at the end ofaddCard()
etc.. This will cause Svelte reactivity to kick in without assigning a new array. This idiom also uses less CPU and memory.$column
store. An empty card looks like a dragged card's shadow where it will be placed when the mouse button is released. There should only be one empty card per Kanban board user. The current implementation allows for many empty cards, causing tricky bugs that are difficult to reproduce.Additional Improvements
This would be a good opportunity to:
store.js
that aren't usedDeferred
The following issues apply to multiuser scenarios. Since multiuser mode will not be enabled for this particular issue, they can be addressed later.