Search code examples
google-drive-apigoogle-drive-realtime-api

What is Model.beginCreationCompoundOperation for?


Operations that occur during model initialization don't end up in the undo history, so what is the purpose of Model.beginCreationCompoundOperation, as opposed to Model.beginCompoundOperation? My best guess is that it used internally to wrap the initialization function call into a compound operation and was not meant to be public.

Documentation of method


Solution

  • Your guess is correct - beginCreationCompoundOperation is used to wrap the initialization function call so that we know that the changes made were used to create the initial document state, which (among other things) can't be undone.

    This function was not meant to be public. Calling it during model initialization will fail immediately, and if it is called after model initialization the changes will refuse to commit on the server and you will need to reload (a creation compound operation can only be applied once - this is what prevents the creation from occurring multiple times if you create a document and then immediately load it on multiple machines).

    This function will be removed in a future update to the Realtime API.