-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(document): add $createModifiedPathsSnapshot()
, $restoreModifiedPathsSnapshot()
, $clearModifiedPaths()
#14699
Conversation
…edPathsSnapshot()`, `$clearModifiedPaths()` Fix #14268
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some minor suggestions
Co-authored-by: hasezoey <[email protected]>
Co-authored-by: hasezoey <[email protected]>
Co-authored-by: hasezoey <[email protected]>
* The function profile can look like: | ||
* this.forEach(state1, fn); // iterates over all paths in state1 | ||
* this.forEach(state1, state2, fn); // iterates over all paths in state1 or state2 | ||
* this.forEach(fn); // iterates over all paths in all states | ||
* | ||
* @param {String} [state] | ||
* @param {String} [state] | ||
* @param {Function} callback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The function profile can look like: | |
* this.forEach(state1, fn); // iterates over all paths in state1 | |
* this.forEach(state1, state2, fn); // iterates over all paths in state1 or state2 | |
* this.forEach(fn); // iterates over all paths in all states | |
* | |
* @param {String} [state] | |
* @param {String} [state] | |
* @param {Function} callback |
from what i can still tell, this function does not take any arugments, does it? (also the documented code above has no relation to this function
Fix #14268
Summary
$createModifiedPathsSnapshot()
takes a snapshot of the document's current change tracking state, without modifying the document's properties.$restoreModifiedPathsSnapshot()
restores the document's change tracking state to a given snapshot.Primarily useful for custom transaction wrappers like #14268. When you modify a document in a transaction and that document was created outside of the transaction, you may need to restore the document's change tracking state if the transaction was aborted.
As part of making this work, I also moved
Model.prototype.$__delta
and supporting code toDocument.prototype.$__delta
. Otherwise,getChanges()
crashes on subdocuments because subdocuments don't have a$__delta
function.Examples