Skip to content

Instantly share code, notes, and snippets.

@soxjke soxjke/AppState.swift
Last active Oct 30, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.