Last active
October 19, 2024 08:52
-
-
Save KhayalSuleymani/a32ca1c7cfaf9c8825f96a81f8e671d4 to your computer and use it in GitHub Desktop.
mvvm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Common | |
class PasscodeViewModel: ViewModel<PasscodeViewItem> { | |
@discardableResult | |
override func move(by c: C<AuthorizeRoute>) -> Self { | |
onSelect(weaks { this, event in | |
switch event { | |
case let .passcode(state): | |
switch state { | |
case let .set(passcode): | |
c.move(to: .passcode(.again(passcode))) | |
case let .again(passcode): | |
this.service.s1.request(.init(passcode: passcode)) { result in | |
switch result { | |
case .success: | |
c.move(.dashboard(.set(passcode))) | |
case let .failure(e): | |
this.render(state: .error(e, nil)) | |
} | |
} | |
case _: | |
break | |
} | |
case _: | |
scanf(self) | |
} | |
}) | |
return self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment