Global Variable Oriented Programming
summary
Walks through a concrete re‑implementation of SwiftUI’s environment for UIKit: uses Combine (ObservableObject + @Published), an @propertyWrapper global<T> that reads a registered instance from a singleton Environment, and runtime reflection to discover wrapped properties. Key implementation details: store AnyCancellable sinks, post filtered NotificationCenter updates on the main queue, and solve generic covariance via an AnyGlobal protocol. Demo app has three tabs; toggling a value updates all views instantly, showing the approach works but needs careful notification filtering.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 4:03Singletons
- 6:18Environment Singletons
- 8:02Swift UI
- 11:40Swift UI Environment
- 12:19App Overview
- 14:13Publishing Changes
- 15:22Environment Singleton
- 19:17Handle Updates
- 22:18Global Properties
- 25:10Reflection
- 29:46Covariance
- 33:09Conclusion








