This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ResourceCacheTest.swift | |
// Test (iOS) | |
// | |
// Created by Malcolm Hall on 08/05/2024. | |
// | |
import SwiftUI | |
import AsyncAlgorithms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
// AsyncObservableTest.ContentView() in your app struct | |
struct AsyncObservableTest { | |
@Observable | |
class Content { | |
var counter = 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
struct AlertConfig: AlertPresentable { | |
var isPresented: Bool = false { | |
didSet { | |
if !isPresented { | |
dismissAction?() | |
dismissAction = nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Counter: Identifiable, Equatable { | |
let id = UUID() | |
var count = 0 | |
} | |
struct ContentView: View { | |
@State var counters: [Counter] = [.init(), .init(), .init()] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Counter: Identifiable, Equatable { | |
let id = UUID() | |
var count = 0 | |
} | |
struct SortedCounters { | |
var _counters: [Binding<Counter>] = [] | |
var counters: [Binding<Counter>] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
@Observable | |
class Counter: Identifiable { | |
var count = 0 | |
} | |
@Observable | |
class Model { | |
var counters: [Counter] = [.init(), .init(), .init()] |