So, I have a database API, that can hold other API’s such as GlobalMap, GlobalArray and etc as values. The problem is that if I save those API’s as values in the database, they would have different YDoc from the databases one. Is it possible to transact/subscribe to changes in the children from the database API?
// database API, transact method
// db is an object holding methods, doc is the YDoc
db.transact = f => {
doc.transact(() => {
f();
});
};
const db = await createDatabase('db');
const accounts = await createGlobalMap('accounts');
accounts.set('Akhat', 100);
accounts.set('John', 200);
db.set('accounts', accounts);
db.transact(() => { //doesn't trigger observe method, since change is in the GlobalMap not in the Database
db.get('accounts').set('Akhat', 50);
db.get('accounts').set('John', 250);
});