CoreLocation Store using CacheStore

LocationCacheStore

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.

LocationStore

public typealias LocationStore = Store<LocationStoreKey, LocationStoreAction, LocationStoreDependency>

Keys

/// `LocationStore` Keys
///     - location: CLLocation
public enum LocationStoreKey {
    case location // CLLocation
}

Actions

/// `LocationStore` Actions
public enum LocationStoreAction {
    case updateLocation
    case locationUpdated(CLLocation?)
}

Dependency

/// `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
    }
}

StoreActionHandler

/// Higher-order StoreActionHandler
public func locationStoreActionHandler(
    withActionHandler actionHandler: StoreActionHandler<LocationStoreKey, LocationStoreAction, LocationStoreDependency>? = nil
) -> StoreActionHandler<LocationStoreKey, LocationStoreAction, LocationStoreDependency>

DefaultLocationStore

public class DefaultLocationStore: LocationStore

GitHub

View Github