Any tips on creating a bi-directional "lens" between documents?

I’m curious if anyone has tried to sync two documents with different representations of the same data.

For example, I have a 3D world with position, rotation, etc. for objects. I also have a TODO list with description and done/not done state.

I’d like to make it so that adding an item to the TODO list populates the 3D world with an object–and vice versa, so that if the object’s name is changed, the TODO list item’s description changes.

I suppose it would be the basis for just about any API endpoint that “edits” a Yjs document. You could have one-way sync (e.g. a weather API that modifies the 3D world document to show weather images in the background); or, you could have two-way sync like the TODO list example.

Has anyone tried something like this? Any tips, tricks, or battle stories?

think this is just the same advice as any data store. Normalize your data so that you separate data and hold links between things separately. Basically you want to partition your data separately and keep links between data separate as well so you can interact with it, change it and view it with as much flexibility as possible. Your main issues will be how you update data so that you do not get in to a state where a change from one view will ruin it for another, so you want to make sure that the viewers of data are robust and you keep history so that anything that could break it can be backed out later.

So no specific advice, just keep to good principals and things will work fine, don’t tie your data to how it is viewed and work on abstractions in each app that are robust and can back out of error states

1 Like