Skip to content

claustrofob/FeatureFactoryExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages