Skip to content

Commit

Permalink
expose clear persistence function
Browse files Browse the repository at this point in the history
  • Loading branch information
sherryshao committed Mar 15, 2024
1 parent 9d2f39a commit a8a931e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Sources/FirebaseFirestore/Firestore+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ public class Firestore {
}
}

public func clearPersistence(completion: @escaping () -> Void) {
let future = swift_firebase.swift_cxx_shims.firebase.firestore.firestore_clear_persistence(impl)
future.setCompletion({
DispatchQueue.main.async {
completion()
}
})
}

public func clearPersistence() async {
await withCheckedContinuation { continuation in
let future = swift_firebase.swift_cxx_shims.firebase.firestore.firestore_clear_persistence(impl)
future.setCompletion({
continuation.resume()
})
}
}

public func document(_ documentPath: String) -> DocumentReference {
swift_firebase.swift_cxx_shims.firebase.firestore.firestore_document(impl, std.string(documentPath))
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/firebase/include/FirebaseFirestore.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ firestore_set_settings(::firebase::firestore::Firestore *firestore, ::firebase::
return firestore->set_settings(settings);
}

inline VoidFuture
firestore_clear_persistence(::firebase::firestore::Firestore *firestore) {
return VoidFuture::From(firestore->ClearPersistence());
}

inline ::firebase::firestore::DocumentReference
firestore_document(::firebase::firestore::Firestore *firestore,
const ::std::string &document_path) {
Expand Down

0 comments on commit a8a931e

Please sign in to comment.