Last active
January 8, 2020 11:33
-
-
Save cipolleschi/a69fe7d5508311fef952755de0dd24f8 to your computer and use it in GitHub Desktop.
Proposal to remove the GlobalHak
This file contains 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 UIKit | |
// MARK: - Ramen State | |
public struct RamenState: AnyStateWithRamen, AnyLegacyState { | |
public var monetizationState: MonetizationState { | |
get { return monetizationState(from: self.monopolyState) } | |
} | |
var monopolyState: MonopolyState | |
} | |
public protocol AnyStateWithRamen { | |
var monetizationState: MonetizationState { get } | |
} | |
internal protocol AnyLegacyState { | |
var monopolyState: MonopolyState { get set } | |
} | |
internal extension RamenState { | |
func monetizationState(from monopolyState: MonopolyState) -> MonetizationState { | |
return MonetizationState(isReady: monopolyState.productFetched) | |
} | |
} | |
// MARK: - Monetization | |
public struct MonetizationState { | |
var isReady: Bool | |
} | |
// MARK: - Legacy | |
struct MonopolyState { | |
var productFetched: Bool | |
} | |
struct SetProductsFetched { | |
func updatedState(state: inout State) { | |
guard var legacyState = state as? AnyLegacyState else { | |
fatalError() | |
} | |
legacyState.monopolyState.productFetched = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment