Adding callback to be called when a document is patched.