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

Expose clear persistence function #50

Merged
merged 1 commit into from
Mar 15, 2024
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
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()
})
}
}
sherryshao marked this conversation as resolved.
Show resolved Hide resolved

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
Loading