-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
3 changed files
with
51 additions
and
2 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
48 changes: 48 additions & 0 deletions
48
HMH_Tuist_iOS/Projects/Domain/Sources/UseCase/My/MyUseCase.swift
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,48 @@ | ||
// | ||
// MyUseCase.swift | ||
// Domain | ||
// | ||
// Created by 류희재 on 11/26/24. | ||
// Copyright © 2024 HMH-iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
import Core | ||
|
||
public protocol MyPageUseCaseType { | ||
func getUserDate() -> AnyPublisher<User, UserError> | ||
func logout() | ||
func revokeUser() | ||
} | ||
|
||
final class MyPageUseCase: MyPageUseCaseType { | ||
private let userRepository: UserRepositoryType | ||
private var cancelBag = CancelBag() | ||
|
||
init(userRepository: UserRepositoryType) { | ||
self.userRepository = userRepository | ||
} | ||
|
||
func getUserDate() -> AnyPublisher<User, UserError> { | ||
userRepository.getUserData() | ||
.map { $0 } | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
func logout() { | ||
userRepository.logout() | ||
.sink { _ in | ||
} receiveValue: { _ in | ||
UserManager.shared.clearLogout() | ||
}.store(in: cancelBag) | ||
} | ||
|
||
func revokeUser() { | ||
userRepository.deleteAccount() | ||
.sink { _ in | ||
} receiveValue: { _ in | ||
UserManager.shared.revokeData() | ||
}.store(in: cancelBag) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ import Combine | |
|
||
import Core | ||
import DSKit | ||
import Domain | ||
|
||
class MyPageViewModel: ObservableObject { | ||
|
||
|