Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    erwan boehm
    @boehm-e
    Well @kevinraz , it seems to be solved, I don't know what I changed to do it but it works x)
    Thank you for your help :)
    Mezriss
    @Mezriss
    Hi, I'm using Yjs with indexeddb provider and I've noticed that when I delete data from document (several mb at once) space taken by indexeddb isn't really going down. Is there a way to force Yjs to flush deleted data?
    Kevin Jahns
    @dmonad
    It will go down eventually. We store incremental updates, but they will eventually be merged - this is when you will see size-reduction in the database.

    You can merge updates manually by calling

    ```js

    import { storeState } from 'y-indexeddb'
    
    storeState(indexeddbPersistence, true)
    Chris Morgan
    @drpotato

    @dmonad why does y-websocket broadcast a sync step 2 during websocket connection: https://github.com/yjs/y-websocket/blob/master/src/y-websocket.js#L354 ? It's being called with an undefined state vector that will result in the entire state being encoded as an update and sent.

    On a similar vein, if two client documents produce the same state vector do they need to exchange updates?

    Kevin Jahns
    @dmonad
    This is only for broadcastchannel communication (no network)
    ie cross-tab communication in the browser

    On a similar vein, if two client documents produce the same state vector do they need to exchange updates?

    Yes

    state vectors don't sync delete sets.
    Stinker winker
    @shiroraven:matrix.org
    [m]
    Hello there! I am working on a collaborative editor that is using Milkdown, a wrapper around prosemirror... I am making use of the y-websocket server but it seems like my browser is sending multiple handshake attempts to the server? I am not exactly sure what is happening and I was hoping someone here can help me figure out the source of the resulting drop in performance.
    I am not used to websockets sending multiple 101 responses, I am assuming this is not how it should look?
    I am quite new to all this, if you require me to send more info / code snippets, please let me know
    Kevin Jahns
    @dmonad
    It seems that your y-websocket server is not reachable. I assume you deployed it somewhere behind a proxy. Maybe the proxy doesn't support websockets. That's really not a lot to go on..
    Chris Morgan
    @drpotato

    state vectors don't sync delete sets.

    That makes sense, so would comparing snapshots be sufficient? I've done some testing and it appears to be the case…

    Zac
    @zacevelynn:matrix.org
    [m]

    Hi, I'd like to ask you a question.I used Y.Undomanager. When multiple clients modify the same data, a problem occurred that I did not solve.
    for example,
    Client A:

    1. create a piece of data {a: 'aaa'}.
      2.{a: 'aaa'} => {a: 'bbb'}.
      Client B: {a: 'bbb'} => {a: 'ccc'}.

    At this time,when Client A presses Command + Z, I want the data to be restored to {a: 'aaa'}, but it actually removed that data.

    How to solve this situation?

    Kevin Jahns
    @dmonad
    @drpotato That should work most of the time. However, the encoding is not consistent (the same snapshot can be encoded differently). I think there's a ticket somewhere to make snapshot encoding consistent.
    @zacevelynn:matrix.org Actually, nothing should happen, since your changes were overwritten by a remote client. If you want, you can describe the steps for reproduction in a ticket and we can talk about it more specifically.
    2 replies
    FindAPattern
    @FindAPattern
    @dmonad Just wanted to say thanks for the fantastic framework. It has taken a few months of learning, but we've finally got everything implemented in our product and are about to release collaborative editing in our next major update. Looking forward to making enough money to sponsor your incredible work (and maybe paying to get some feedback on the autoscaling websocket/redis server we built). Thanks!!!
    Kevin Jahns
    @dmonad
    Thanks @FindAPattern! I'm happy when people build something cool with Yjs. Btw, we have a weekly Y Community meeting that you could use to discuss your redis solution - https://twitter.com/kevin_jahns/status/1441088253189263374
    janwirth
    @janwirth
    Hey I have some questions wrt yjs
    What's the best approach if my application state is held in a separate store? Do I dispatch individual Creat / Update / Delete Events that are applied to my YJS doc and then I listen to events when the change was successful and lastly apply the event / mutation to my store
    Or is there another way I should do it?
    Kevin Jahns
    @dmonad
    This might be what you are looking for: https://syncedstore.org/docs/ It automatically syncs a third-party store with Yjs. if your (custom) store is not supported, you have to write the binding yourself. THen yes, you have to sync store events with Yjs and vice versa.
    janwirth
    @janwirth
    I'm actually using elm
    I think I got the way the events are fired etc now so it's working
    Now I have to sort out my own spaghetti code, thank you
    Ilias Tsangaris
    @ilias-t
    Love Yjs & thanks in advance for the help! Is it considered bad practice to delete items from the share map in a Doc with doc.share.delete('<array_key>')? I'm getting an unexpected case error when I do that and then try to encodeStateAsUpdate. Maybe I'm doing it the wrong way—the goal is to be able to have a removed Array in one doc sync to another doc.
    Ilias Tsangaris
    @ilias-t
    Not sure if I'm answering my own question here but maybe the solution here is to use a YMap that contains YArray's and then just delete the key from that YMap (rather than the share Map)...
    Kevin Jahns
    @dmonad
    Hi @ilias-t, yeah, you shouldn't delete objects from ydoc.share. Basically, you can't delete root-level types once you inserted content into them. You are right, Y.Map is the way to go here :wink:
    Xiaomeng Zhang
    @zhang123cnn

    Hey folks, just want to come back and say I have a really positive experience with Yjs so far. It significantly helped us resolve many perf issues we had with Automerge. So we could ship our end product with good quality bar. Love it!

    I do have one follow up question though. In some of our use cases, we would like to have some control over how we want Yjs to resolve conflicts on value reassignment.

    Example 1 - We would like end users to resolve conflicts themselves:
    Let's say we have YDoc { "key": "someValue" } where two nodes A and B update it regularly. Sometimes, A and B may update {"key": "valueA" } and {"key": "valueB"} at the same time. In such case, only "valueA" or "valueB" is picked by yjs and the unpicked value would be dropped. However we would love Yjs to notify us when it happens so our product code could pass this two writes to users to decide which value they want.

    Example 2 - We would like to minimise the chance of an old write overwriting a newer write.
    Let's say we have YDoc { "key": 0 } where a group of nodes update it regularly. This yDoc keeps getting updated by a number of nodes. And after some time, yDoc becomes {"key": 9999}. One of the node had some network issues from the start so it still sees the initial value 0. Now this old node gets network recovered and it starts to set the value to {"key": 1}. Currently this could overwrite the latest value { "key": 9999 } which is bad in many of use cases. So we would like to somehow detect some update is based on a really old version so it would be "deprioritized" when CRDT merges the value.

    Does anyone have any thoughts on how we could gain control of conflict resolution with Yjs? Automerge has a conflict API which helps our examples here so I am wondering if there are some perspective solutions in Yjs too.

    Many thanks for reading this long question. Would really appreciate your thoughts.

    Ilias Tsangaris
    @ilias-t
    @dmonad haha good to know, that solution should work great—thanks for the tip!
    Ilias Tsangaris
    @ilias-t
    Is there a recommended way to convert a JSON structure into a Yjs doc that's essentially the reverse of the doc.toJSON() method? No worries if not, I can just do it programmatically, but it seems like it could be a nice utility function if I'm not missing something.
    Ilias Tsangaris
    @ilias-t
    Ah I forgot doc.toJSON() was deprecated, so maybe nvm
    Kevin Jahns
    @dmonad
    Hi @zhang123cnn, happy that you like Yjs. Currently, there is no such API in Yjs :/ It is, in theory, possible to calculate the conflicting items, and prioritize one of them. However, that would require deep knowledge of Yjs without an API.
    4 replies
    @ilias-t If you end up writing a utility function to convert a JSON to a Y.Map/Y.Array, let me know! We could put it into y-utility. There are already several state-binding libraries (see https://github.com/yjs/yjs#bindings), that do the very same thing.
    4 replies
    rcypher
    @MatthewMathica_gitlab
    Hey, cool library. I'm currently re-writing chat app into several Yjs docs, messages are items of Y.Array when someone add new message we sync via update from .on('update') listener. When someone receives this update we need to do some kind of validation of underlying message before its added. I can see the message inside update but I'm not sure if I can parse that safely or there is some kind of api to do it. Thanks
    Kevin Jahns
    @dmonad
    Hey @MatthewMathica_gitlab this question comes up all the time and has been answered multiple times already. Can you please look for an answer in discuss.yjs.dev ? If you dont find it open a new topic there.
    rcypher
    @MatthewMathica_gitlab
    Ok I found it from source code, thanks. (Y.decodeUpdate)
    Vojtech Rinik
    @vojto
    CleanShot 2022-05-11 at 14.41.02@2x.png
    hey guys, what's a good way to check for empty diff, such as this?
    Vojtech Rinik
    @vojto
    CleanShot 2022-05-11 at 14.50.20@2x.png
    I'm guessing this is not it :D
    Kevin Jahns
    @dmonad

    Well.. there is not utility function for this in Yjs, so this is probably the easiest way to check for an empty update.

    You can also check ydoc.store.clients.size === 0 - true iff there are no updates on the document.

    Vojtech Rinik
    @vojto

    Well.. there is not utility function for this in Yjs, so this is probably the easiest way to check for an empty update.

    You can also check ydoc.store.clients.size === 0 - true iff there are no updates on the document.

    thank you!

    Lucas Van Bramer
    @lucasvanbramer
    Hi there - I submitted an issue a few weeks ago re: a BroadcastChannel falling out of sync. Once again, thank you for fixing that! I do have one follow-up question: Assuming I do actually need to make a change to the document from within an observer function body, is there a recommended way to do so? I've considered just setting a short timeout or patching together something with useEffect in React to allow for the observer call to complete, but I figure there has to be a best practice for this (that perhaps I am just too new as a JS developer to know). Thanks!
    Lucas Van Bramer
    @lucasvanbramer
    I'm mainly asking because my components seem to be working correctly, but I get "Changed the client-id because another client seems to be using it." every time my observer (or the observer I register to another object inside the original observer call) fires.
    Kevin Jahns
    @dmonad
    Observers changing the YDoc can often lead to infinite loops. So I generally avoid doing it. The issue you mentioned was fixed, so you should be able to do that safely now. However, I timeout is always a good idea; then the change won't be fired in the same execution thread which prevents a bunch of other potential issues.
    yankovichv
    @yankovichv

    Good afternoon. I'm trying to build a Yjs-based service for syncing notes, tasks, and browser bookmarks. I feel that Yjs is what I need. But I'm afraid I don't understand how to use it to its full potential yet.

    Can someone please advise me? I would be willing to pay. Other than that, my spoken English is not very good; if you speak Russian, that would be awesome :)