CoreLocation State Store
What is CacheStore
?
CacheStore
is a SwiftUI state management framework that uses a dictionary as the state. Scoping creates a single source of truth for the parent state. CacheStore
uses c
, which a simple composition framework. c
has the ability to create transformations that are either unidirectional or bidirectional.
public typealias LocationStore = Store<LocationStoreKey, LocationStoreAction, LocationStoreDependency>
/// `LocationStore` Keys
/// - location: CLLocation
public enum LocationStoreKey {
case location // CLLocation
}
/// `LocationStore` Actions
public enum LocationStoreAction {
case updateLocation
case locationUpdated(CLLocation?)
}
/// `LocationStore` Dependency
public struct LocationStoreDependency {
public var shouldContinuouslyUpdate: Bool
public var updateLocation: () async -> CLLocation?
public init(
shouldContinuouslyUpdate: Bool = true,
updateLocation: @escaping () async -> CLLocation?
) {
self.shouldContinuouslyUpdate = shouldContinuouslyUpdate
self.updateLocation = updateLocation
}
}
/// Higher-order StoreActionHandler
public func locationStoreActionHandler(
withActionHandler actionHandler: StoreActionHandler<LocationStoreKey, LocationStoreAction, LocationStoreDependency>? = nil
) -> StoreActionHandler<LocationStoreKey, LocationStoreAction, LocationStoreDependency>
public class DefaultLocationStore: LocationStore