An example project demonstrating proper handling of view models in SwiftUI + MVVM architecture.
See the accompanying posts:
In the first version of FeatureFactory, the view model is created inside a .task modifier and unwrapped inside a ZStack. While functional, this approach can cause visible flickering in certain situations, since the view briefly renders before the view model becomes available.
An improved second version uses a lazy var to access the view model. This avoids any delay in instantiating the view model, eliminating the flickering side effects present in the original implementation. However it introduces a small overhead by allocating extra ViewModelState class on every view update.