Slide 4
Slide 4 text
ࣄͷൃ
internal class SenderImpl @Inject constructor(
private val application: Application,
private val apiClient: ApiClient,
@Named("io") private val ioScheduler: Scheduler
) : Sender {
override fun sendEvent(extras: Map): Completable = getHoge()
.flatMapCompletable {
apiClient.send(
ParameterJson(
time = System.currentTimeMillis(),
hogeId = it,
appName = "ϝχϡʔζ"
)
)
}.subscribeOn(ioScheduler)
private fun getHoge(): Maybe = Maybe.create { emitter ->
try {
val hoge = Hoge.getHoge(application)
emitter.onSuccess(hoge.id)
} catch (e: Exception) {
emitter.onError(e)
}
}
}