Your code for storing the updates looks correct. I’m doing something very similar in my y-websocket server. When you call bindState it will store the current doc and then subscribe to updates.
If it doesn’t seem to be working at all, I would verify the individual components: Is bindState called at the right time, is LeveldbPersistence able to persist the doc (even test with a hard-coded doc), etc. It seems like a usage issue rather than an issue with the core logic.
I also tried in the outer of subscribe upate, still could not work. does you have a demo cod how to get the document text? @raine I have work for this for a long time and tried so many ways, still could not fix it.
Are you trying to get the “document text” or the binary updates? You need to persist the binary updates. Though perhaps you want to access the text content of the document for a different reason?
I want to get the text content, not the binary content. I have made a latex online editor, when the users edit the latex project document online(one project may contains many latex document), I want to flush the newest document to disk for the next step latex compile. the latex compile engine read the document on disk, could not read document from leveldb. I am already using what you pasted project.
I tried what you provide, it works. Thank you. I found the ytext value did not change when I edit context in the UI editor, but I will tried to found out the reason, your solution works.