-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirebaseDependency.swift
More file actions
47 lines (39 loc) · 1.03 KB
/
Copy pathFirebaseDependency.swift
File metadata and controls
47 lines (39 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// FirebaseDependency.swift
// DevLogInfra
//
// Created by opfic on 6/5/26.
//
import FirebaseAuth
import FirebaseFirestore
import FirebaseFunctions
import FirebaseMessaging
struct FirebaseDependency<Value> {
private let value: Value
init(value: Value) {
self.value = value
}
}
extension FirebaseDependency where Value == Firestore {
func document(_ path: String) -> DocumentReference {
value.document(path)
}
}
extension FirebaseDependency where Value == Functions {
func httpsCallable(_ name: some RawRepresentable<String>) -> HTTPSCallable {
value.httpsCallable(name)
}
}
extension FirebaseDependency where Value == Messaging {
func token() async throws -> String {
try await value.token()
}
func deleteToken() async throws {
try await value.deleteToken()
}
}
extension FirebaseDependency where Value == AuthStateDidChangeListenerHandle {
func removeAuthStateDidChangeListener() {
Auth.auth().removeStateDidChangeListener(value)
}
}