State Management Using View Model in SwiftUI

preview_player
Показать описание
In this video, Mohammad Azam will demonstrate how view models can be used to maintain state in SwiftUI applications.

If you want to support my work then please consider buying one of my courses below. The links below already has coupon attached which will give you the best deal possible. Thank you for your support!

SwiftUI - Declarative Interfaces for any Apple Device

Mastering RxSwift in iOS

MVVM Design Pattern Using Swift in iOS

Mastering ARKit for iOS

Intermediate and Advanced iOS - Build Real World Apps

The Complete Guide to JSON Parsing in Swift

Data Structures and Algorithms in Swift

Design Patterns in iOS Using Swift

Mastering MapKit for iOS

Machine Learning in iOS Using Swift

Mastering Firebase for iOS Using Swift

Mastering Server Side Swift Using Vapor 3

NodeJS - The Complete Developer Bootcamp

The Complete Guide to Lean Controllers in iOS
Рекомендации по теме
Комментарии
Автор

Change log as of late Feb 2021: (Mr. Azam, you can pin this, if you'd like!)

1. (2:25) In LoginViewModel.swift, BindableObject has changed to ObservableObject
2. (2:25) The variables will need to have @Published in front of them
3. (2:43) the "willChange" line is no longer needed
4. (3:41) In ContentView.swift, @ObjectBinding has changed to @StateObject
5. (4:06) The "self." is no longer necessary for the two variables
6. (10:34) The "willSet" code isn't necessary, but I'm not sure how you'd handle the DispatchQueue functionality

toastrecon
Автор

Suggestion: the View layer shouldn't create Authentication instances (or ViewModels for that matter. The View layer should be kept as simple, dumb as possible.
Instead, the AuthenticationService should be already provided through the ViewModel, and the ViewModel is injected into the View.
Ideally, the View would not even know about an AuthenticationService. All it would do is pass along values to the ViewModel, which would in turn handle authentication, privately.
Cheers.

wmblemania
Автор

hi, can you do a next video for this one?


I'm using xcode 11 beta 5 and I'm implementing a sign up scene where the user clicks Sign Up button and it will sign them up and navigate to the next scene, but I found out that NavigationLink cannot do both things at the same time, it won't navigate if I call the sign up function on the onTapGesture. It'll still sign up successfully but won't navigation. If I take out the signup code, then it'll navigate normally....Any comment on this issue? thanks

nve-nick
visit shbcf.ru