Skip to content

Instantly share code, notes, and snippets.

@KhayalSuleymani
Last active October 19, 2024 14:13
Show Gist options
  • Save KhayalSuleymani/995565e6d6ed5e3db176800e1cd18039 to your computer and use it in GitHub Desktop.
Save KhayalSuleymani/995565e6d6ed5e3db176800e1cd18039 to your computer and use it in GitHub Desktop.
import Common
typealias HomeView = InsetTableView<HomeViewItem>
class HomeViewModel: ViewModel<HomeViewItem> {
@discardableResult
override func move(by c: C<HomeRoute>) -> Self {
service.s1.requestUser(weaks { _weakSelf, result in
switch result {
case .success(let user):
obj.set(&obj.userInfo, user)
_weakSelf.service.s1.requestCards(id: user.id) {
switch $0 {
case let .success(cards):
obj.set(&obj.cards, cards)
_weakSelf.render(state: .success(obj))
case let .failure(e):
scanf(e)
}
}.requestAccounts(id: user.id) {
switch $0 {
case let .success(accounts):
obj.set(&obj.accounts, accounts)
_weakSelf.render(state: .success(obj))
case let .failure(e):
scanf(e)
}
}.requestTemplates(id: user.id) {
switch $0 {
case let .success(templates):
obj.set(&obj.templates, templates)
_weakSelf.render(state: .success(obj))
case let .failure(e):
scanf(e)
}
}.requestOperations(id: user.id) {
switch $0 {
case let .success(operations):
obj.set(&obj.operations, operations)
_weakSelf.render(state: .success(obj))
case let .failure(e):
scanf(e)
}
}
case .failure(let e):
this.render(state: .failure(e))
}
})
return self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment