Post

Replies

Boosts

Views

Activity

Reply to Stop using MVVM for SwiftUI
@Appeloper I know that this is a pretty old thread. But this is interesting. So basically a Store is just an observed Repository then? It's not even a VM. Because a VM is also handling the state of a view such as error handling when the fetching / updating the model (ie. should we display a Toast or Alert or a fullscreen View, what error message to show, the color scheme, the callback when the alert or view is closed, etc). Or when to display or hide activity indicator. Etc. A VM is per view controller / feature while from what I've seen so far, a Store is just per model. So where do you put these other logics? On the corresponding Views? So that means the Views will hold both the layout logic and some business logic? CMIIW.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’25
Reply to Apple Sign In stuck on simulator
The code is very similar to the tutorials and documentation. The difference is I am using MVVM+RxSwift. Here it is: final class SignInViewModel {    struct Input {     let emailText: DriverString     let passwordText: DriverString     let signInTapped: SignalVoid     let appleSignInTapped: SignalVoid   }    let openDashboardScreen: SignalSignInViewParam    init(handleSignIn: @escaping (String, String) - ObservableSignInViewParam,         handleAppleSignIn: @escaping (String) - ObservableSignInViewParam,         input: Input) {     let signInEvent = input.signInTapped       .asObservable()       .withLatestFrom(Observable.combineLatest(input.emailText.asObservable(),                             input.passwordText.asObservable()))       .flatMapLatest { (arg) - ObservableSignInViewParam in         let (email, password) = arg         return handleSignIn(email, password)       }           if #available(iOS 13, *) {       let appleSignInEvent = input.appleSignInTapped         .compactMap { [weak self] in return self?.createAuthController() }         .flatMapLatest { (authController: ASAuthorizationController) - ObservableSignInViewParam in           return authController.rx             .didCompleteWithAuthorization /* The delegate control event using RxCocoa's DelegateProxy */             .compactMap { authorization in               guard let credential = authorization.credential as? ASAuthorizationAppleIDCredential,                  let authCodeData = credential.authorizationCode,                  let authCode = String(data: authCodeData, encoding: .utf8)               else { return nil }                               return authCode             }             .flatMapLatest { (authCode) - ObservableSignInViewParam in               return handleAppleSignIn(authCode) /* Send auth code to server and will return SignInViewParam on success */             }         }               openDashboardScreen = Observable.merge(signInEvent, appleSignInEvent)         .asSignal(onErrorSignalWith: .never())     } else {       openDashboardScreen = signInEvent.asSignal(onErrorSignalWith: .never())     }   }       @available(iOS 13.0, *)   private func createAuthController() - ASAuthorizationController {     let appleIdProvider = ASAuthorizationAppleIDProvider()     let request = appleIdProvider.createRequest()     request.requestedScopes = [.email, .fullName]           let authController = ASAuthorizationController(authorizationRequests: [request])     authController.performRequests()     return authController   } } I tried using imperative instead of reactive like the tutorials, and it still stuck on the Apple ID password screen.
Mar ’21