This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1 | |
| public protocol DIContainer { | |
| func register<DependencyType>(type: DependencyType.Type, dependency: DependencyType) | |
| func resolve<DependencyType>(type: DependencyType.Type) -> DependencyType | |
| } | |
| // 2 | |
| public class DependencyContainer { | |
| public static let shared: DIContainer = DependencyContainer() | |
| private var registeredDependencies: [String: Any] = [:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // MARK: - ResolveMode | |
| /// Allow you to choose how you'd like the dependency resolved | |
| public enum ResolveMode { | |
| /// Indicate that you'd like a new dependency created of that type or key requested | |
| case new | |
| /// Indicate that you'd like the global dependency of that type or key requested | |
| case shared |