-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForecastsAction.kt
24 lines (22 loc) · 977 Bytes
/
ForecastsAction.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package me.soushin.sunshine.ui.base.forecasts
import io.reactivex.schedulers.Schedulers
import me.soushin.sunshine.data.repository.OpenWeatherMapRepository
import me.soushin.sunshine.ui.base.error.Err
import me.soushin.sunshine.ui.base.error.ErrorDispatcher
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class ForecastsAction @Inject constructor(private val forecastsDispatcher: ForecastsDispatcher,
private val errorDispatcher: ErrorDispatcher,
private val openWeatherMapRepository: OpenWeatherMapRepository) {
fun findByDaily() {
openWeatherMapRepository.findForecastByDaily()
.subscribeOn(Schedulers.io())
.subscribe({
forecastsDispatcher.forecastsProcessor.onNext(it)
}, {
errorDispatcher.onError(Err(it.message))
})
}
}