-
Notifications
You must be signed in to change notification settings - Fork 682
/
AppDIContainer.swift
executable file
·36 lines (31 loc) · 1.3 KB
/
AppDIContainer.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
import Foundation
final class AppDIContainer {
lazy var appConfiguration = AppConfiguration()
// MARK: - Network
lazy var apiDataTransferService: DataTransferService = {
let config = ApiDataNetworkConfig(
baseURL: URL(string: appConfiguration.apiBaseURL)!,
queryParameters: [
"api_key": appConfiguration.apiKey,
"language": NSLocale.preferredLanguages.first ?? "en"
]
)
let apiDataNetwork = DefaultNetworkService(config: config)
return DefaultDataTransferService(with: apiDataNetwork)
}()
lazy var imageDataTransferService: DataTransferService = {
let config = ApiDataNetworkConfig(
baseURL: URL(string: appConfiguration.imagesBaseURL)!
)
let imagesDataNetwork = DefaultNetworkService(config: config)
return DefaultDataTransferService(with: imagesDataNetwork)
}()
// MARK: - DIContainers of scenes
func makeMoviesSceneDIContainer() -> MoviesSceneDIContainer {
let dependencies = MoviesSceneDIContainer.Dependencies(
apiDataTransferService: apiDataTransferService,
imageDataTransferService: imageDataTransferService
)
return MoviesSceneDIContainer(dependencies: dependencies)
}
}