Skip to content

Instantly share code, notes, and snippets.

@fabiothiroki
Created January 29, 2018 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiothiroki/c7798ad55f468f8fdd4ff7c10f00c38f to your computer and use it in GitHub Desktop.
Save fabiothiroki/c7798ad55f468f8fdd4ff7c10f00c38f to your computer and use it in GitHub Desktop.
App State
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