Files
singlechat/ios/YpChat/Core/AppServices.swift
Torsten Schulz (local) bfe28a25fa
All checks were successful
Deploy SingleChat / deploy (push) Successful in 40s
android app, extension of stats
2026-08-10 14:03:34 +02:00

39 lines
1.3 KiB
Swift
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)
}
}