Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Integrating SyncedStore with third-party library

$
0
0

I've got a Svelte application and set up SyncedStore to synchronize stuff over a websocket. Everything is working great.

But there is some part of my state managed by a third-party library. (SvelteFlow) I have to pass two Svelte stores to this library and it's going to use the Svelte store API to make changes to them.

This means I can catch updates to this part of my state. But the updates take the form of whole new objects. Instead of doc.something.something.foo = 3 I get a whole new object to replace doc.something, that only differs from the original in foo.

I think if I simply set doc.something = newSomething it will make SyncedStore think that the whole object is replaced and it won't be able to sync fine-grained changes. (E.g. someone changes doc.something.something.bar at the same time.) Correct me if this is wrong.

What's the right way to do this? Could I use Lodash's merge to update the SyncedStore document from newSomething?


Viewing all articles
Browse latest Browse all 1541

Trending Articles