Skip to content

Commit

Permalink
[Fix] #259 DIContainer register 삭제 및 DefaultNearByStopUseCase 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
isakatty committed May 8, 2024
1 parent 8d85cb6 commit 951c9dc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 45 deletions.
9 changes: 0 additions & 9 deletions Projects/App/Sources/AppDelegate+Register.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation

import Widget
import Core
import CoreDataService
import Data
Expand Down Expand Up @@ -93,13 +92,5 @@ extension AppDelegate {
type: RegularAlarmEditingService.self,
regularAlarmEditingService
)

// DIContainer.register(
// type: NearByStopUseCase.self,
// DefaultNearByStopUseCase(
// stationListRepository: stationListRepository,
// locationService: locationService
// )
// )
}
}
41 changes: 8 additions & 33 deletions Projects/App/Widget/NearByStop/DefaultNearByStopUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Domain

import RxSwift

final class DefaultNearByStopUseCase: NearByStopUseCase {
final public class DefaultNearByStopUseCase: NearByStopUseCase {
private let stationListRepository: StationListRepository
private let locationService: LocationService

Expand All @@ -32,48 +32,23 @@ final class DefaultNearByStopUseCase: NearByStopUseCase {
) -> Observable<(BusStopInfoResponse, String)> {
locationService.locationStatus
.withUnretained(self)
.map { useCase, status in
.flatMap { useCase, status in
print("✅ : \(status) <- locationStatus")

var response: BusStopInfoResponse
var distanceStr: String
let requestMessage = "확인하려면 위치사용을 허용해주세요"
let waitingMessage = "위치 정보 가져오는 중..."
let errorMessage = "위치 정보를 가져올 수 없습니다"
switch status {
case .authorized(let location),
.alwaysAllowed(let location):
(response, distanceStr) = useCase.stationListRepository
.getNearByStopInfo(startPointLocation: location)
case .waitingForLocation:
response = .init(
busStopName: waitingMessage,
busStopId: "",
direction: "",
longitude: "126.979620",
latitude: "37.570028"
)
distanceStr = ""
case .notDetermined, .denied:
response = .init(
busStopName: requestMessage,
busStopId: "",
direction: "",
longitude: "126.979620",
latitude: "37.570028"
)
distanceStr = ""
case .error:
response = .init(
busStopName: errorMessage,
busStopId: "",
direction: "",
longitude: "126.979620",
latitude: "37.570028"
)
distanceStr = ""

return Observable<(BusStopInfoResponse, String)>
.just((response, distanceStr))
default:
return .empty()
}
return (response, distanceStr)

}
}
}
3 changes: 1 addition & 2 deletions Projects/App/Widget/NearByStop/NearByStopProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ struct NearByStopProvider: TimelineProvider {
stationListRepository: DefaultStationListRepository(),
locationService: DefaultLocationService()
)
// @Injected(NearByStopUseCase.self) var useCase: NearByStopUseCase

private let disposeBag = DisposeBag()

Expand Down Expand Up @@ -66,7 +65,7 @@ struct NearByStopProvider: TimelineProvider {
// 데이터 업데이트를 위한 타임라인 생성
let timeline = Timeline(
entries: entries,
policy: .never
policy: .after(.now.addingTimeInterval(60))
)
print("❤️‍🔥 \(timeline)")

Expand Down
2 changes: 1 addition & 1 deletion Projects/App/Widget/NearByStop/NearByStopUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ import Domain

import RxSwift

protocol NearByStopUseCase {
public protocol NearByStopUseCase {
func updateNearByStop() -> Observable<(BusStopInfoResponse, String)>
}

0 comments on commit 951c9dc

Please sign in to comment.