Swiftpack.co - 0xLeif/LocationCacheStore as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by 0xLeif.
0xLeif/LocationCacheStore 0.1.0
CoreLocation Store using CacheStore
⭐️ 2
🕓 3 weeks ago
iOS macOS watchOS
.package(url: "https://github.com/0xLeif/LocationCacheStore.git", from: "0.1.0")

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

link
Stars: 2
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics