Coder Social home page Coder Social logo

Persisting State: Documentation? about y-websocket HOT 12 OPEN

yjs avatar yjs commented on May 23, 2024
Persisting State: Documentation?

from y-websocket.

Comments (12)

dmonad avatar dmonad commented on May 23, 2024 8

Hey @canadaduane , I'm currently updating y-redis and y-leveldb. I'll also restructure the API that adds persistence to y-websocket. Until now, I expected people to clone the y-websocket server, but I think it makes sense to at least allow users to share persistence modules properly.

from y-websocket.

mikkorantalainen avatar mikkorantalainen commented on May 23, 2024 2

Any new info about persisting state? I'd prefer pushing and pulling the persisting state to/from Postgres database so any pointers about that would be great.

from y-websocket.

dmonad avatar dmonad commented on May 23, 2024 1

Hi @rebolyte

No update.

In the limited time I have for this project (very little funding), I'm working on the new Yjs documentation site.

y-leveldb is stable now and could also be used over the different databases that levelup supports.

from y-websocket.

jnbarlow avatar jnbarlow commented on May 23, 2024 1

@dmonad The sample project has :

// Super hacky way to provide a initial value from the client, if
		// you plan to use y-websocket in prod you probably should provide the
		// initial state from the server.

but I can't find docs and/or figure out how to send the state up on the initial connection.
I've got this far:

utils.setPersistence({
	bindState: async (docName, yDoc) => {
		log.debug('bindState:', docName);
		//load from db and seed?
		const document = yDoc.getArray();
		console.log(document.toJSON());
		document.insert(0, [{ type: 'paragraph', children: [{ text: 'Hello world from server!' }] }]);
		console.log(document.toJSON());

		yDoc.on('update', update => {
			//do some crazy saving here.
			const doc = utils.getYDoc(docName).getArray('content').toJSON();
			log.debug(docName);
			log.debug(JSON.stringify(doc, null, 2));
		});
	},
	writeState: async (docName, yDoc) => {
		log.debug('writeState:', docName);
		//this fires on connection close
	}
});

and document has the initial state, but I just for the life of me can't figure out how to push that to the front end.

from y-websocket.

hanspagel avatar hanspagel commented on May 23, 2024 1

Just wanted to chime in and say that we’re working on a wrapper on top of y-websocket, y-redis, and y-leveldb (in collaboration with Kevin) called hocuspocus. If you struggle to put together all the building blocks, it’s probably worth a look.

It’s only available for GitHub sponsors for now, but we’ll publish it as a MIT-licensed package in the next months. If you can’t afford sponsoring our efforts, reach out to [email protected] and I’ll invite you manually.

from y-websocket.

canadaduane avatar canadaduane commented on May 23, 2024

That would be fantastic! Thank you.

from y-websocket.

renieravin avatar renieravin commented on May 23, 2024

Hey @dmonad , any luck on this front? Would love to implement persistence in Yjs 13!

from y-websocket.

dmonad avatar dmonad commented on May 23, 2024

@renieravin Sure, I'd love to get a contribution on y-leveldb.

If you want to get started, it would be best to start a new project based on y-indexeddb and rewrite it based on leveldb. I recommend to use [leveldown]https://github.com/Level/leveldown) unless there is a good alternative.

from y-websocket.

dmonad avatar dmonad commented on May 23, 2024

Actually, @renieravin I just might have found a sponsor for the leveldb adapter. I'll let you know if it works out :)

from y-websocket.

anilgulecha avatar anilgulecha commented on May 23, 2024

@dmonad was any update made on this persistence feature? The README does talk about:

PORT=1234 YPERSISTENCE=./dbDir node ./node_modules/y-websocket/bin/server.js

So is this available for use, or a WIP?

from y-websocket.

AdventureBeard avatar AdventureBeard commented on May 23, 2024

@mikkorantalainen, you might be able to rig up a connection to Postgres by leveraging y-leveldb + level + SQLdown, though I'd be careful with SQLdown, as it looks pretty old and opinionated. You might use SQLdown as inspiration for fulfilling the level interface in a way that best suits your application's needs. Haven't tried level + SQLdown myself yet, but probably will pretty soon. Will report back if so.

from y-websocket.

rebolyte avatar rebolyte commented on May 23, 2024

Any update here? Being able to drop in y-redis here would be 🔥

from y-websocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.