-
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
4 changed files
with
80 additions
and
41 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
49 changes: 49 additions & 0 deletions
49
...tures/MyPageFeature/Sources/Refactor_MyFeature_Combine/Domain/UseCase/MyPageUseCase.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,49 @@ | ||
// | ||
// MyPageUseCase.swift | ||
// MyPageFeature | ||
// | ||
// Created by 류희재 on 9/3/24. | ||
// Copyright © 2024 HMH-iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
import Core | ||
import Domain | ||
|
||
protocol MyPageUseCaseType { | ||
func getUserDate() -> AnyPublisher<GetUserDataResponseDTO, Error> | ||
func logout() | ||
func revokeUser() | ||
} | ||
|
||
final class MyPageUseCase: MyPageUseCaseType { | ||
private var container: DIContainer | ||
private var cancelBag = CancelBag() | ||
|
||
init(container: DIContainer) { | ||
self.container = container | ||
} | ||
|
||
func getUserDate() -> AnyPublisher<GetUserDataResponseDTO, Error> { | ||
container.services.userService.getUserData() | ||
.map { $0.data! } | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
func logout() { | ||
container.services.authService.logoutUser() | ||
.sink { _ in | ||
} receiveValue: { _ in | ||
UserManager.shared.clearLogout() | ||
}.store(in: cancelBag) | ||
} | ||
|
||
func revokeUser() { | ||
container.services.authService.revokeUser() | ||
.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
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