Skip to content

Commit

Permalink
Make UserDataReader tree-shakeable (#3333)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Jul 6, 2020
1 parent c7aa053 commit 064cf2e
Show file tree
Hide file tree
Showing 11 changed files with 2,717 additions and 551 deletions.
2 changes: 2 additions & 0 deletions .changeset/four-melons-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
22 changes: 15 additions & 7 deletions packages/firestore/exp/src/api/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ import * as firestore from '../../index';
import { Firestore } from './database';
import {
DocumentKeyReference,
ParsedUpdateData
ParsedUpdateData,
parseSetData,
parseUpdateData,
parseUpdateVarargs
} from '../../../src/api/user_data_reader';
import { debugAssert } from '../../../src/util/assert';
import { cast } from '../../../lite/src/api/util';
import { DocumentSnapshot, QuerySnapshot } from './snapshot';
import {
addDocSnapshotListener,
addSnapshotsInSyncListener,
addQuerySnapshotListener,
addSnapshotsInSyncListener,
applyFirestoreDataConverter,
getDocsViaSnapshotListener,
getDocViaSnapshotListener,
Expand Down Expand Up @@ -175,7 +178,8 @@ export function setDoc<T>(
options
);
const dataReader = newUserDataReader(firestore);
const parsed = dataReader.parseSetData(
const parsed = parseSetData(
dataReader,
'setDoc',
ref._key,
convertedValue,
Expand Down Expand Up @@ -215,15 +219,17 @@ export function updateDoc(
typeof fieldOrUpdateData === 'string' ||
fieldOrUpdateData instanceof FieldPath
) {
parsed = dataReader.parseUpdateVarargs(
parsed = parseUpdateVarargs(
dataReader,
'updateDoc',
ref._key,
fieldOrUpdateData,
value,
moreFieldsAndValues
);
} else {
parsed = dataReader.parseUpdateData(
parsed = parseUpdateData(
dataReader,
'updateDoc',
ref._key,
fieldOrUpdateData
Expand Down Expand Up @@ -262,11 +268,13 @@ export function addDoc<T>(
const convertedValue = applyFirestoreDataConverter(collRef._converter, data);

const dataReader = newUserDataReader(collRef.firestore);
const parsed = dataReader.parseSetData(
const parsed = parseSetData(
dataReader,
'addDoc',
docRef._key,
convertedValue,
collRef._converter !== null
collRef._converter !== null,
{}
);

return firestore
Expand Down
Loading

0 comments on commit 064cf2e

Please sign in to comment.