8000 Correct all AddSnapshotListener calls. Try std::string and FieldValue… · firebase/snippets-cpp@6a151d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a151d7

Browse files
committed
Correct all AddSnapshotListener calls. Try std::string and FieldValue::String.
1 parent bc44104 commit 6a151d7

File tree

1 file changed

+6
-6
lines changed
  • firestore/android/FirestoreSnippetsCpp/app/src/main/cpp

1 file changed

+6
-6
lines changed

firestore/android/FirestoreSnippetsCpp/app/src/main/cpp/snippets.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ void ReadDataEventsForLocalChanges(firebase::firestore::Firestore* db) {
646646
// [START listen_document_local]
647647
DocumentReference doc_ref = db->Collection("cities").Document("SF");
648648
doc_ref.AddSnapshotListener([](const DocumentSnapshot& snapshot,
649-
Error error) {
649+
Error error, const std::string& errorMsg) {
650650
if (error == Error::kErrorOk) {
651651
const char* source =
652652
snapshot.metadata().has_pending_writes() ? "Local" : "Server";
@@ -690,7 +690,7 @@ void ReadDataEventsForMetadataChanges(firebase::firestore::Firestore* db) {
690690
DocumentReference doc_ref = db->Collection("cities").Document("SF");
691691
doc_ref.AddSnapshotListener(
692692
MetadataChanges::kInclude,
693-
[](const DocumentSnapshot& snapshot, Error error) { /* ... */ });
693+
[](const DocumentSnapshot& snapshot, Error error, const std::string& errorMsg) { /* ... */ });
694694
// [END listen_with_metadata]
695695
}
696696

@@ -708,7 +708,7 @@ void ReadDataListenToMultipleDocumentsInCollection(
708708
// [START listen_multiple]
709709
db->Collection("cities")
710710
.WhereEqualTo("state", FieldValue::String("CA"))
711-
.AddSnapshotListener([](const QuerySnapshot& snapshot, Error error) {
711+
.AddSnapshotListener([](const QuerySnapshot& snapshot, Error error, const std::string& errorMsg) {
712712
if (error == Error::kErrorOk) {
713713
std::vector<std::string> cities;
714714
std::cout << "Current cities in CA: " << error << '\n';
@@ -740,7 +740,7 @@ void ReadDataViewChangesBetweenSnapshots(firebase::firestore::Firestore* db) {
740740
// [START listen_diffs]
741741
db->Collection("cities")
742742
.WhereEqualTo("state", FieldValue::String("CA"))
743-
.AddSnapshotListener([](const QuerySnapshot& snapshot, Error error) {
743+
.AddSnapshotListener([](const QuerySnapshot& snapshot, Error error, const std::string& errorMsg) {
744744
if (error == Error::kErrorOk) {
745745
for (const DocumentChange& dc : snapshot.DocumentChanges()) {
746746
switch (dc.type()) {
@@ -779,7 +779,7 @@ void ReadDataDetachListener(firebase::firestore::Firestore* db) {
779779
// Add a listener
780780
Query query = db->Collection("cities");
781781
ListenerRegistration registration = query.AddSnapshotListener(
782-
[](const QuerySnapshot& snapshot, Error error) { /* ... */ });
782+
[](const QuerySnapshot& snapshot, Error error, const std::string& errorMsg) { /* ... */ });
783783
// Stop listening to changes
784784
registration.Remove();
785785
// [END detach_listener]
@@ -881,7 +881,7 @@ void ReadDataArrayInNotInOperators(firebase::firestore::Firestore* db) {
881881
// [START cpp_in_filter]
882882
CollectionReference cities_ref = db->Collection("cities");
883883

884-
cities_ref.WhereIn("country", std::vector<FieldValue::String> {"USA", "Japan"});
884+
cities_ref.WhereIn("country", std::vector<std::string>{FieldValue::String("USA"), FieldValue::String("Japan")});
885885
// [END cpp_in_filter]
886886

887887
// [START cpp_not_in_filter]

0 commit comments

Comments
 (0)
0