There are a few nuances to worry about with this. The user can call document:close or document:save inside of the callback. They can error or yield in the callback.
The behavior I decided to go with is the following:
If the callback errors, the return promise will reject but the document will still count as closed and document:close cannot be called again even though the data isn't saved and the lock isn't removed.
document:close and document:save will error if called inside of the callback.
document:beforeClose will error if called more than once.
There are a few nuances to worry about with this. The user can call
document:close
ordocument:save
inside of the callback. They can error or yield in the callback.The behavior I decided to go with is the following:
document:close
cannot be called again even though the data isn't saved and the lock isn't removed.document:close
anddocument:save
will error if called inside of the callback.document:beforeClose
will error if called more than once.