-
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.
Browse files
Browse the repository at this point in the history
Refactor [#94] Service Layer 리펙토링
- Loading branch information
Showing
142 changed files
with
2,715 additions
and
1,766 deletions.
There are no files selected for viewing
13 changes: 5 additions & 8 deletions
13
HMH_Tuist_iOS/HMH-Tuist-iOS.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
26 changes: 26 additions & 0 deletions
26
HMH_Tuist_iOS/Projects/Core/Sources/Extension/Combine+/CancelBag.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,26 @@ | ||
// | ||
// File.swift | ||
// Core | ||
// | ||
// Created by 류희재 on 10/30/24. | ||
// Copyright © 2024 HMH-iOS. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
open class CancelBag { | ||
public var subscriptions = Set<AnyCancellable>() | ||
|
||
public func cancel() { | ||
subscriptions.forEach { $0.cancel() } | ||
subscriptions.removeAll() | ||
} | ||
|
||
public init() { } | ||
} | ||
|
||
extension AnyCancellable { | ||
public func store(in cancelBag: CancelBag) { | ||
cancelBag.subscriptions.insert(self) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
HMH_Tuist_iOS/Projects/Core/Sources/Extension/Combine+/Mapper.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,32 @@ | ||
// | ||
// Combine+.swift | ||
// Core | ||
// | ||
// Created by 류희재 on 10/29/24. | ||
// Copyright © 2024 HMH-iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
|
||
public extension Publisher { | ||
/// Output을 Void로 변환하는 메서드 | ||
func asVoid() -> AnyPublisher<Void, Failure> { | ||
self.map { _ in () } | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
/// Error 타입을 일반 Error로 변환하는 메서드 | ||
func mapToGeneralError() -> AnyPublisher<Output, Error> { | ||
self.mapError { $0 as Error } | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
/// Output을 Void로 변환하고, Failure 타입을 일반 Error로 변환하는 메서드 | ||
func asVoidWithGeneralError() -> AnyPublisher<Void, Error> { | ||
self.map { _ in () } | ||
.mapError { $0 as Error } | ||
.eraseToAnyPublisher() | ||
} | ||
} | ||
|
Empty file.
Oops, something went wrong.