-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] #388 - UseCase 주입 및 Repository 구현
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
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
45 changes: 45 additions & 0 deletions
45
SOPT-iOS/Projects/Domain/Sources/UseCase/DailySoptuneUseCase.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,45 @@ | ||
// | ||
// DailySoptuneUseCase.swift | ||
// Domain | ||
// | ||
// Created by 강윤서 on 9/27/24. | ||
// Copyright © 2024 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
import Core | ||
|
||
public protocol DailySoptuneUseCase { | ||
var dailySoptuneResult: PassthroughSubject<DailySoptuneResultModel, Never> { get } | ||
|
||
func getDailySoptuneResult(date: String) | ||
} | ||
|
||
|
||
public class DefaultDailySoptuneUseCase { | ||
|
||
private let repository: DailySoptuneRepositoyInterface | ||
private let cancelBag = CancelBag() | ||
|
||
public let dailySoptuneResult = PassthroughSubject<DailySoptuneResultModel, Never>() | ||
|
||
public init(repository: DailySoptuneRepositoyInterface) { | ||
self.repository = repository | ||
} | ||
} | ||
|
||
extension DefaultDailySoptuneUseCase: DailySoptuneUseCase { | ||
public func getDailySoptuneResult(date: String) { | ||
repository.getDailySoptuneResult(date: date) | ||
.sink { event in | ||
print("GetDailySoptuneResult State: \(event)") | ||
} receiveValue: { [weak self] dailySoptuneResult in | ||
self?.dailySoptuneResult.send(dailySoptuneResult) | ||
} | ||
.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