Hi, I have two questions about the initialization before observation.
I am now using Y.Map to store shared data and try to add initial values to make a default structure of our document.
For example, we used the following initialization function which is called before the observation function
export const initializeBank = () => {
// initialize local
setBank(produce((bank) => {
Object.keys(bank).forEach((key, idx) => {
delete bank[key];
})
}));
setBankKey(0);
// initialize yMap
yMap.clear()
yMap.set('bank', new Y.Map())
yMap.set('numBankKey', 0)
}
However, when I execute the function before observation, it does not initialize data inside the yMap.
To see the problem deeper, I tried to execute the observation function after 2 seconds while the initialization function is still executed when the app loads. However, it still does not empty and initialize the yMap object.
When I print the yMap inside the initialization function, it prints the initialized object. However, It isn’t initialized when I call yMap again in the other functions, which is very weird. Is there anything I missed?