Last active
February 7, 2022 22:59
-
-
Save victorbrndls/b62a80c048bc12c98f2b9d6941937466 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LocalDocumentsView.java | |
Document getDocument(DocumentKey key) { | |
// 1. Get all mutations for the given document | |
List<MutationBatch> batches = mutationQueue.getAllMutationBatchesAffectingDocumentKey(key); | |
return getDocument(key, batches); | |
} | |
private Document getDocument(DocumentKey key, List<MutationBatch> inBatches) { | |
// 2. Fetch the remote version of the given document from the local cache | |
MutableDocument document = remoteDocumentCache.get(key); | |
for (MutationBatch batch : inBatches) { | |
// 3. Apply all mutations to the remote document | |
batch.applyToLocalView(document); | |
} | |
return document; // = RemoteDocument + Active(LocalMutations) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment