Skip to content

Commit e3da80a

Browse files
WIP Tree-Shakeable Mutations
1 parent 982acf9 commit e3da80a

File tree

10 files changed

+805
-950
lines changed

10 files changed

+805
-950
lines changed

packages/firestore/lite/test/dependencies.json

Lines changed: 27 additions & 249 deletions
Large diffs are not rendered by default.

packages/firestore/src/api/field_value.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from '../model/transform_operation';
3232
import { ParseContext, parseData, UserDataSource } from './user_data_reader';
3333
import { debugAssert } from '../util/assert';
34+
import { toNumber } from '../remote/serializer';
3435

3536
/**
3637
* An opaque base class for FieldValue sentinel objects in our public API that
@@ -188,17 +189,10 @@ export class NumericIncrementFieldValueImpl extends SerializableFieldValue {
188189
}
189190

190191
_toFieldTransform(context: ParseContext): FieldTransform {
191-
const parseContext = createSentinelChildContext(
192-
this,
193-
context,
194-
/*array=*/ false
195-
);
196-
const operand = parseData(this._operand, parseContext)!;
197-
const numericIncrement = new NumericIncrementTransformOperation(
198-
context.serializer,
199-
operand
192+
return new FieldTransform(
193+
context.path!,
194+
toNumber(context.serializer, this._operand)
200195
);
201-
return new FieldTransform(context.path!, numericIncrement);
202196
}
203197

204198
isEqual(other: FieldValue): boolean {

packages/firestore/src/local/local_documents_view.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { ResourcePath } from '../model/path';
3535
import { debugAssert } from '../util/assert';
3636
import { IndexManager } from './index_manager';
3737
import { MutationQueue } from './mutation_queue';
38-
import { PatchMutation } from '../model/mutation';
38+
import { applyMutationToLocalView, PatchMutation } from '../model/mutation';
3939
import { PersistenceTransaction } from './persistence';
4040
import { PersistencePromise } from './persistence_promise';
4141
import { RemoteDocumentCache } from './remote_document_cache';
@@ -258,7 +258,8 @@ export class LocalDocumentsView {
258258
for (const mutation of batch.mutations) {
259259
const key = mutation.key;
260260
const baseDoc = results.get(key);
261-
const mutatedDoc = mutation.applyToLocalView(
261+
const mutatedDoc = applyMutationToLocalView(
262+
mutation,
262263
baseDoc,
263264
baseDoc,
264265
batch.localWriteTime

packages/firestore/src/local/local_store.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ import {
3030
} from '../model/collections';
3131
import { MaybeDocument, NoDocument } from '../model/document';
3232
import { DocumentKey } from '../model/document_key';
33-
import { Mutation, PatchMutation, Precondition } from '../model/mutation';
33+
import {
34+
Mutation,
35+
PatchMutation,
36+
Precondition,
37+
extractBaseValue
38+
} from '../model/mutation';
3439
import {
3540
BATCHID_UNKNOWN,
3641
MutationBatch,
@@ -449,7 +454,8 @@ class LocalStoreImpl implements LocalStore {
449454
const baseMutations: Mutation[] = [];
450455

451456
for (const mutation of mutations) {
452-
const baseValue = mutation.extractBaseValue(
457+
const baseValue = extractBaseValue(
458+
mutation,
453459
existingDocs.get(mutation.key)
454460
);
455461
if (baseValue != null) {

0 commit comments

Comments
 (0)