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 TestError: Swift.Error { | |
case uploadFailed | |
} | |
class Album { | |
let pages: [Page] = [] | |
} | |
class Page {} | |
class UploadServiceImpl { | |
private(set) lazy var addAction = Action<Album, Void, TestError>(execute:self.addActionBlock) | |
private lazy var pageAction = Action<Page, Void, TestError>(execute:self.pageActionBlock) |
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 | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
let _ = AppStore.shared | |
let _ = LocationService.shared | |
let _ = WeatherService.shared |
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
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
let _ = AppStore.shared | |
let _ = LocationService.shared | |
let _ = WeatherService.shared | |
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
class WeatherService { | |
private struct Constants { | |
static let apiKey = "z74X7aKpZlip02a5Wlrq9R70JkDnOZsq" | |
} | |
static let shared: WeatherService = WeatherService() | |
fileprivate lazy var sessionManager: SessionManager = self.setupSessionManager() | |
fileprivate let appStore: AppStore = AppStore.shared | |
private init() { | |
setupObserving() |
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 Foundation | |
public struct AppError: Swift.Error { | |
public enum AppErrorReason { | |
public enum API: String { | |
case wrong_password | |
case invalid_email | |
} | |
public enum Validation: String { | |
case invalid_phone_number |
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 Foundation | |
enum AppEvent { | |
case locationPermissionResult(success: Bool) | |
case locationRequest | |
case locationResult(latitude: Double, longitude: Double, timestamp: TimeInterval, error: Error?) | |
case geopositionRequest | |
case geopositionResult(geoposition: Geoposition, error: Error?) | |
case weatherRequest | |
case weatherResult(current: Weather, forecast: [Weather], error: Error?) |
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 Foundation | |
enum LocationState { | |
case notYetRequested | |
case notAvailable | |
case available | |
} | |
enum LocationRequestState { | |
case none |
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 Foundation | |
import Redux_ReactiveSwift | |
extension AppState: Defaultable { | |
static var defaultValue: AppState = AppState(location: AppLocation(locationState: .notYetRequested, | |
locationRequestState: .none), | |
weather: AppWeather(geopositionRequestState: .none, | |
weatherRequestState: .none)) | |
} |
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 Foundation | |
import CoreLocation | |
import ReactiveSwift | |
class LocationService: NSObject { | |
static let shared: LocationService = LocationService() | |
fileprivate lazy var locationManager: CLLocationManager = self.setupLocationManager() | |
fileprivate let appStore: AppStore = AppStore.shared | |
private override init() { |
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 Foundation | |
import Quick | |
import Nimble | |
@testable import Simple_Weather_App | |
class GeopositionSpec: QuickSpec { | |
override func spec() { | |
let geopositionJSON: [String: Any] = try! JSONSerialization.jsonObject(with: try! Data.init(contentsOf: Bundle.test.url(forResource: "Geoposition", withExtension: "json")!)) as! [String: Any] | |
describe("parsing") { | |
let geoposition = try? Geoposition(JSON: geopositionJSON) |