Skip to content

About

An example project demonstrating proper handling of view models in SwiftUI + MVVM architecture

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

FeatureFactoryExample

An example project demonstrating proper handling of view models in SwiftUI + MVVM architecture.

See the accompanying posts:

Reddit

Linkedin

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.

About

An example project demonstrating proper handling of view models in SwiftUI + MVVM architecture

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages