Skip to content

Instantly share code, notes, and snippets.

@soxjke
Last active October 30, 2017 19:39
Show Gist options
  • Save soxjke/0cc9bf43994103b08c6d26064f19e9b3 to your computer and use it in GitHub Desktop.
Save soxjke/0cc9bf43994103b08c6d26064f19e9b3 to your computer and use it in GitHub Desktop.
import Foundation
enum LocationState {
case notYetRequested
case notAvailable
case available
}
enum LocationRequestState {
case none
case updating
case success(latitude: Double, longitude: Double, timestamp: TimeInterval)
case error(error: Error)
}
struct AppLocation {
let locationState: LocationState
let locationRequestState: LocationRequestState
}
enum GeopositionRequestState {
case none
case updating
case success(geoposition: Geoposition)
case error(error: Error)
}
enum WeatherRequestState {
case none
case updating
case success(currentWeather: Weather, forecast: [Weather])
case error(error: Error)
}
struct AppWeather {
let geopositionRequestState: GeopositionRequestState
let weatherRequestState: WeatherRequestState
}
struct AppState {
let location: AppLocation
let weather: AppWeather
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment