forked from kudoleh/iOS-Clean-Architecture-MVVM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AppDIContainer.swift
executable file
·35 lines (29 loc) · 1.42 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
//
// DIContainer.swift
// ExampleMVVM
//
// Created by Oleh Kudinov on 01.10.18.
//
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)
}
}