Swiftpack.co - nightwill/CLLocationManagerPublisher as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by nightwill.
nightwill/CLLocationManagerPublisher 1.0.0
An extension for CLLocationManager for supporting publishers
⭐️ 0
🕓 4 days ago
iOS macOS
.package(url: "https://github.com/nightwill/CLLocationManagerPublisher.git", from: "1.0.0")

CLLocationManagerPublisher

Usage

struct ContentView: View {

    @State private var locationPublisher = CLLocationManager.locationPublisher().first().replaceError(with: [])
    @State private var locationString = ""
    
    var body: some View {
        Text("Location \(locationString)")
            .onReceive(locationPublisher) { locations in
                locationString = locations.map(\.textDescription).joined(separator: "\n")
            }
    }
}

private extension CLLocation {

    var textDescription: String {
        String(format: "%.5f,%.5f %@", coordinate.latitude, coordinate.longitude, timestamp.description)
    }

}

GitHub

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

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