This file contains hidden or 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
{ | |
"products": [ | |
{ | |
"id": "1", | |
"name": "Spaghetti", | |
"description": "Spaghetti with tomato sauce", | |
"price": "10.00 Euro", | |
"max_basket_count": 1 | |
}, | |
{ |
This file contains hidden or 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 LocationObserver { | |
init(store: AppStore) { | |
[…] | |
store.subscribe(self) { subcription in | |
subcription.select { state in state.lastKnownLocation } | |
} | |
} |
This file contains hidden or 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
// Middleware.swift | |
func startMonitoring([…]) -> Action? { | |
[…] | |
if (appDidBecomeActive && isAuthorized) || (isSetAuthorized && !isAuthorized) { | |
locationManager.startMonitoringSignificantLocationChanges() | |
locationManager.requestLocation() | |
} | |
return action |
This file contains hidden or 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
extension ViewController: StoreSubscriber { | |
typealias StoreSubscriberStateType = AppState | |
func newState(state: AppState) { | |
[…] | |
authorizationNotDeterminedView.isHidden = state.authorizationStatus != .notDetermined | |
authorizationDeniedView.isHidden = (state.authorizationStatus == .authorizedAlways) || (state.authorizationStatus == .authorizedWhenInUse) | |
} | |
} |
This file contains hidden or 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 AppDelegate: UIResponder, UIApplicationDelegate { | |
[…] | |
private let locationEmitter: LocationEmitter | |
override init() { | |
[…] | |
locationEmitter = LocationEmitter(locationManager: CLLocationManager(), store: appStore) | |
[…] |
This file contains hidden or 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
final class LocationEmitter: NSObject { | |
private let locationManager: CLLocationManager | |
private let store: AppStore | |
init(locationManager: CLLocationManager, store: AppStore) { | |
[…] | |
locationManager.delegate = self | |
[…] | |
} |
This file contains hidden or 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
// Loadable.swift | |
enum Loadable<T> { | |
case initial | |
case loading | |
case value(T) | |
case error(Error) | |
} | |
// AppState.swift | |
struct AppState: StateType { |
This file contains hidden or 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
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
let viewController = window?.rootViewController as! ViewController | |
viewController.store = appStore | |
return true | |
} |
This file contains hidden or 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? | |
private let placesService: PlacesServing | |
private let appStore: AppStore | |
override init() { |
NewerOlder