Skip to content

Instantly share code, notes, and snippets.

@Wouter01
Wouter01 / EnvironmentObservable.swift
Created August 16, 2023 21:05
SwiftUI EnvironmentObservable
import SwiftUI
import Observation
@propertyWrapper
struct EnvironmentObservable<Value: AnyObject & Observable>: DynamicProperty {
@Environment var wrappedValue: Value
public init(_ objectType: Value.Type) {
_wrappedValue = .init(objectType)