Skip to content

Instantly share code, notes, and snippets.

View erezhod's full-sized avatar
🤓
Nerdy

Erez Hod erezhod

🤓
Nerdy
View GitHub Profile
{
"id": "1",
"message": "A storm is coming. Let's get ready for it.",
"status": 200
}
@erezhod
erezhod / AsyncStreamBroadcast.swift
Last active March 3, 2025 15:25
A broadcaster that allows multiple consumers to receive the same updates from a single source. Based on `AsyncStream` but designed for multiple subscribers.
import Foundation
/**
A broadcaster that allows multiple consumers to receive the same updates from a single source.
Similar to `AsyncStream` but designed for multiple subscribers.
Example usage
```swift
final class AuthRepository {
private let authStateStream = AsyncStreamBroadcast<AuthState>()
@erezhod
erezhod / AsyncSVGImage.swift
Last active October 28, 2025 22:24
Async SVG image loading view for SwiftUI
//
// AsyncSVGImage.swift
// AsyncSVGImage
//
// Created by Erez Hod on 1/21/24.
//
import Darwin
import Foundation
import UIKit
@erezhod
erezhod / Persist.swift
Last active April 13, 2023 08:10
Swift `UserDefaults` Persist Property Wrapper with `App Groups` support
import Foundation
enum UserDefaultsGroup: String {
case standard
case shared = "group.com.your.AppGroupName" // For sharing among App Groups
}
@propertyWrapper
struct Persist<T: Codable> {
struct Wrapper<T>: Codable where T: Codable {