- Updated the application namespace and ID from "net.ypchat.app" to "de.ypchat.android" for better alignment with branding. - Increased Gradle heap size settings to optimize build performance. - Disabled dependency constraints to simplify dependency management. - Removed obsolete files related to the previous application structure, including MainActivity, YpChatApp, and various core components, streamlining the codebase. These changes collectively enhance the application's configuration and structure, improving maintainability and performance.
39 lines
1.3 KiB
Swift
39 lines
1.3 KiB
Swift
import Combine
|
||
import Foundation
|
||
|
||
/// DI-Container light – analog `AppContainer.kt` inkl. `ChatRepository`.
|
||
final class AppServices: ObservableObject {
|
||
let api: RestAPIClient
|
||
let socket: SocketClient
|
||
let profileStore: ProfileStore
|
||
let repository: ChatRepository
|
||
|
||
private var cancellables = Set<AnyCancellable>()
|
||
|
||
init() {
|
||
let config = URLSessionConfiguration.default
|
||
config.httpCookieStorage = .shared
|
||
config.httpCookieAcceptPolicy = .always
|
||
config.httpShouldSetCookies = true
|
||
config.timeoutIntervalForRequest = 15
|
||
config.timeoutIntervalForResource = 30
|
||
let urlSession = URLSession(configuration: config)
|
||
|
||
let api = RestAPIClient(baseURLString: AppConfig.baseURL, session: urlSession)
|
||
let socket = SocketClient(baseURL: AppConfig.baseURL)
|
||
let profileStore = ProfileStore()
|
||
|
||
self.api = api
|
||
self.socket = socket
|
||
self.profileStore = profileStore
|
||
self.repository = ChatRepository(api: api, socket: socket, profileStore: profileStore)
|
||
|
||
repository.objectWillChange
|
||
.receive(on: RunLoop.main)
|
||
.sink { [weak self] _ in
|
||
self?.objectWillChange.send()
|
||
}
|
||
.store(in: &cancellables)
|
||
}
|
||
}
|