Skip to content

Instantly share code, notes, and snippets.

View malhal's full-sized avatar

Malcolm Hall malhal

View GitHub Profile
import SwiftUI
// AsyncObservableTest.ContentView() in your app struct
struct AsyncObservableTest {
@Observable
class Content {
var counter = 0
}
//
// ResourceCacheTest.swift
// Test (iOS)
//
// Created by Malcolm Hall on 08/05/2024.
//
import SwiftUI
import AsyncAlgorithms
@malhal
malhal / CLLocationManager+Combine.swift
Last active May 31, 2024 23:28
A Combine location publisher for CLLocationManager.
// Requirements: a NSLocationWhenInUseUsageDescription entry in Info.plist
// Usage: @State var locator = CLLocationManager.publishLocation()
// and
// .onReceive(locator) { location in
// Improvements needed: Move requestWhenInUseAuthorization into its own publisher and perhaps have a combineLatest pipeline for both authorized and valid location.
// A configuration param to init(), e.g. so each manager can have the same distanceFilter.
import Foundation
import Combine
import CoreLocation