-
Notifications
You must be signed in to change notification settings - Fork 0
/
CBLApp.swift
51 lines (40 loc) · 1.02 KB
/
CBLApp.swift
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
48
49
50
import Foundation
class CBLApp: ObservableObject {
@Published var currentUser: User? = nil
@Published var appConfig: AppConfig
@Published var error: Error? = nil
@Published var databaseState: DatabaseState = .notInitialized
init(configuration: AppConfig){
appConfig = configuration
}
func setCurrentUser(_ user: User?){
DispatchQueue.main.sync {
self.currentUser = user
}
}
func setError(_ error: Error?){
DispatchQueue.main.sync {
self.error = error
}
}
func setDatabaseState(_ state: DatabaseState){
DispatchQueue.main.sync {
self.databaseState = state
}
}
}
struct ConnectionException: Error {
let message: String
}
struct InvalidCredentialsException: Error {
let message: String
}
struct ApplicationUserIsNil: Error {
let message: String
}
struct InvalidEndpointUrl: Error {
let message: String
}
struct InvalidStateError: Error {
let message: String
}