How to determine if a shared type is fresh or not

Hi Kevin!

I’m currently working on some functionality which requires the ability to run some code before a shared type receives its first change. Is there currently any official way to determine if a type is fresh and hasn’t received any modifications yet?

Thank you!

Hi @aartr,

You could check ydoc.store.clients.size === 0 to check if any updates have been applied to the document. Alternatively, there is a provider.on('synced', () => ..) event that is fired when the provider first synced with another client/server.