Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22e273a
commit 730aa33
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// MyPartyViewModel.swift | ||
// Taxi | ||
// | ||
// Created by 이윤영 on 2022/06/15. | ||
// | ||
|
||
import Foundation | ||
|
||
final class MyPartyViewModel: ObservableObject { | ||
@Published private (set) var myPartyList: [TaxiParty] = [] | ||
private let myPartyUseCase: MyTaxiPartyUseCase = MyTaxiPartyUseCase() | ||
|
||
func getMyParties(user: User) { | ||
myPartyUseCase.getMyTaxiParty(user, force: true) { [weak self] taxiParties, error in | ||
guard let self = self, let taxiParties = taxiParties else { | ||
print(error ?? "") | ||
return | ||
} | ||
print("Get MyParties, taxiParties: \(taxiParties)") | ||
self.myPartyList = taxiParties | ||
} | ||
} | ||
|
||
func leaveMyParty(user: User, party: TaxiParty) { | ||
myPartyUseCase.leaveTaxiParty(party, user: user) { [weak self] error in | ||
guard let self = self else { | ||
print(error ?? "") | ||
return | ||
} | ||
print("Leave Party, user:\(user.id), party:\(party.id)") | ||
self.getMyParties(user: user) | ||
} | ||
} | ||
} |