Post

Replies

Boosts

Views

Activity

SwiftUI and MVVM
Hi allI am trying to get my head round how i can achive the following using the MVVM design pattern with SwiftUI.I want to have only 1 instance of a networking operation queue (using OperationQueue) where any view model that needs to send any networking requests but i have heard that creating a Singleton is not preferred and i should be passing the networking queue object around where it is needed.So if i create the instance of the network operation queue in the Scene Delegate and pass them into the ContentView initialiser and store it in an object there to then pass into the views then created.This doesnt seem like good MVVM design practice as from what i understand the View should Own the ViewModel only?What is the best way of achieving this?Thanks
1
0
2.6k
Aug ’19