Skip to content
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

Make UserDataReader tree-shakeable #3333

Merged
merged 9 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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