@EnvironmentObject Is a Branched Global Variable

In SwiftUI, @EnvironmentObject is used to loosely couple any ObservableObject without directly passing it down the view hierarchy, e.g. via parameter injection.

Unlike Singletons and global variables, Environment Objects are local to view hierarchies: different branches in the hierarchy can maintain different object references.

It’s like a “branched global”. That term was coined by Dominik Hauser (@dasdom) on Twitter. That’s quite catchy!

Receive new .