Notifications and business logic


So far my documents seem to be dump containers for arbitrary frontend data. But how do you handle it when you want to have business logic, like notifications that is based on what happens in the frontend. Lets say you have a trello like application and someone deletes a full list. Then you might want to notify the users. Or if you subscribe to certain types of changes.

I imagine you’d want to use the observe function to subscribe to changes on a shared type. Then you can read the delta to determine if a notification should be fired.

I think I need to have the yjs backend logic in my main backend services, so that I can subscribe to changes. I can also attach additional information to the transaction.

Yes, you can use the y-websocket provider to sync changes with your backend. You can use the getYDoc function to retrieve a document on the server-side and subscribe to changes.

But how do you know what has been changed?

The event object contains changed keys and deltas: