Skip to content

Commit 345e691

Browse files
committed
refactor: usecase operator invoke 활용
1 parent 44d2be1 commit 345e691

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

domain/src/main/java/com/stop/domain/usecase/route/GetLastTransportTimeUseCaseImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal class GetLastTransportTimeUseCaseImpl @Inject constructor(
2020

2121
private val allowedSubwayLineForUse = (SUBWAY_LINE_ONE..SUBWAY_LINE_EIGHT)
2222

23-
override suspend fun invoke(itinerary: Itinerary): List<String?> {
23+
override suspend operator fun invoke(itinerary: Itinerary): List<String?> {
2424
var transportIdRequests: List<TransportIdRequest?> = createTransportIdRequests(itinerary)
2525
transportIdRequests = convertStationId(transportIdRequests)
2626
transportIdRequests = convertRouteId(transportIdRequests)

domain/src/main/java/com/stop/domain/usecase/route/GetRouteUseCase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import com.stop.domain.model.route.tmap.RouteRequest
55

66
interface GetRouteUseCase {
77

8-
suspend fun invoke(routeRequest: RouteRequest): List<Itinerary>
8+
suspend operator fun invoke(routeRequest: RouteRequest): List<Itinerary>
99
}

domain/src/main/java/com/stop/domain/usecase/route/GetRouteUseCaseImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
1010
private val routeRepository: RouteRepository
1111
) : GetRouteUseCase {
1212

13-
override suspend fun invoke(routeRequest: RouteRequest): List<Itinerary> {
13+
override suspend operator fun invoke(routeRequest: RouteRequest): List<Itinerary> {
1414
val originItineraries = routeRepository.getRoute(routeRequest)
1515

1616
return originItineraries.fold(listOf()) itinerary@{ itineraries, itinerary ->

presentation/src/main/java/com/stop/ui/route/RouteViewModel.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,14 @@ class RouteViewModel @Inject constructor(
6363
)
6464

6565
viewModelScope.launch(Dispatchers.IO) {
66-
_routeResponse.postValue(getRouteUseCase.invoke(routeRequest))
66+
this@RouteViewModel._routeResponse.postValue(getRouteUseCase(routeRequest))
6767
}
6868
}
6969

7070
fun calculateLastTransportTime(itinerary: Itinerary) {
7171
checkClickedItinerary(itinerary)
7272
viewModelScope.launch(Dispatchers.IO) {
73-
val lastTimeInfo = getLastTransportTimeUseCase(itinerary)
74-
75-
_lastTimeResponse.postValue(lastTimeInfo)
73+
this@RouteViewModel._lastTimeResponse.postValue(getLastTransportTimeUseCase(itinerary))
7674
}
7775
}
7876

0 commit comments

Comments
 (0)