Created
January 29, 2018 21:21
-
-
Save fabiothiroki/c7798ad55f468f8fdd4ff7c10f00c38f to your computer and use it in GitHub Desktop.
App State
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
enum Result { | |
case loading | |
case failed | |
case finished(LocationPlaces) | |
} | |
extension Result: Equatable { | |
static func == (lhs: Result, rhs: Result) -> Bool { | |
switch (lhs, rhs) { | |
case (.loading, .loading): | |
return true | |
case let (.finished(a), .finished(b)): | |
return a == b | |
case (.failed, .failed): | |
return true | |
default: | |
return false | |
} | |
} | |
} | |
struct FetchedPlacesState: StateType { | |
var places: Result = .loading | |
} | |
extension FetchedPlacesState: Equatable { | |
static func == (lhs: FetchedPlacesState, rhs: FetchedPlacesState) -> Bool { | |
return lhs.places == rhs.places | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment