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 Firestore.terminate #51

Merged
merged 1 commit into from
Mar 18, 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
28 changes: 25 additions & 3 deletions Sources/FirebaseFirestore/Firestore+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ public class Firestore {
}
}

public func clearPersistence(completion: @escaping () -> Void) {
public func clearPersistence(completion: (() -> Void)?) {
let future = swift_firebase.swift_cxx_shims.firebase.firestore.firestore_clear_persistence(impl)
future.setCompletion({
DispatchQueue.main.async {
completion()
if let completion {
DispatchQueue.main.async {
completion()
}
}
})
}
Expand All @@ -62,6 +64,26 @@ public class Firestore {
}
}

public func terminate(completion: (() -> Void)?) {
let future = swift_firebase.swift_cxx_shims.firebase.firestore.firestore_terminate(impl)
future.setCompletion({
if let completion {
DispatchQueue.main.async {
completion()
}
}
})
}

public func terminate() async {
await withCheckedContinuation { continuation in
let future = swift_firebase.swift_cxx_shims.firebase.firestore.firestore_terminate(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 @@ -31,6 +31,11 @@ firestore_clear_persistence(::firebase::firestore::Firestore *firestore) {
return VoidFuture::From(firestore->ClearPersistence());
}

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

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