Rok Koncina
04/15/2019, 12:28 PMMohamed Ibrahim
04/16/2019, 7:33 PMnic
04/18/2019, 7:21 PMgetSomeObservable().flatMapSingle { t -> performAPICallWithData(t) }
I don't want to performAPICallWithData
until the first one has completed, and I want to use the result from performAPICallWithData
to determine wether I should perform the next one or complete everythingoday
04/20/2019, 3:33 PMursus
04/20/2019, 10:11 PMursus
04/23/2019, 8:31 PMursus
04/23/2019, 8:32 PMlocke
04/29/2019, 4:39 AMMohamed Ibrahim
04/30/2019, 11:50 AMalexsullivan114
04/30/2019, 6:03 PMObservable.interval
to count down from 30 seconds to zero. After that, I want to use flatMap
and continue another Rx chain. I'm not sure what the best way is to actually know when after that
is. Using flatMap
directly after the interval
call obviously doesn't work since the flatMap
gets called after each tick of the interval. RIght now I'm using materialize
and checking if the notification isOnComplete
. Is that the best way to handle this?ursus
05/02/2019, 6:05 AMursus
05/05/2019, 5:17 PMiex
05/06/2019, 1:31 AMsubscribe(subject)
doesn't return a disposable.alexsullivan114
05/06/2019, 5:33 PMArkadii Ivanov
05/12/2019, 1:49 PMjw
05/13/2019, 3:14 PMursus
05/26/2019, 3:51 AMfun refresh(page: Int) : Completable {
.. call api
database.write(...)
}
(edited)
and now I want to display progressbar while this is happening + progressbar at the end if page > 1 (edited)
the trouble with this is that presentation layer has a query observable opened liek this
ViewModel {
database.fooQuery()
.subscribe { ... post to adapter }
}
which means that this will emit at the time database.write is called
so If map refresh to events of Started, Success, Error
Success will come after the database is refreshed
which to me is weird, since it should be done in one go, but that means refresh would need to return that data too (edited)
tldr; writing to the database is side-effecting - how to deal with that?Mohamed Ibrahim
06/02/2019, 3:10 PMjw
06/04/2019, 12:42 PMursus
06/07/2019, 6:21 AMubu
06/07/2019, 10:31 AMbuffer()
operator, but I just can't get it right.
When having A
, B
, C
, D
, E
, F
emitted one after another with some delay, I would like to have an Observable
emitting: [A]
, [A, B]
, [A,B,C]
, [B, C, D]
, [C, D, E]
, [D, E, F]
. We are only interested in last values, so I suppose, we could use here a Flowable
.
Thanks.ivano
06/13/2019, 7:55 AMursus
06/14/2019, 4:43 PMMohamed Ibrahim
06/16/2019, 1:36 PMMediaPlayer
(in Activity) from viewModel
, and I have another for settings .. now I want the player relay to only skipUntil
the settings emit an enable sound item.
from docs skipUntil
only waits for an Observable to emit at least an item. but what if need to check on that item too, should I use something else or there is something missingmyanmarking
06/18/2019, 3:07 PMmyanmarking
06/19/2019, 9:22 AMObservable.create<Unit> { System.out.println("Yo") }
class PrintObservable: ObservableOnSubscribe<Unit> {
override fun subscribe(emitter: ObservableEmitter<Unit>) {
System.out.println("Yo")
}
}
Observable.create(PrintObservable())
alexsullivan114
06/19/2019, 1:26 PMBehaviorRelay
in the ViewModel
or in the fragment/activity?liminal
06/21/2019, 4:43 AMursus
06/21/2019, 3:25 PMprivate fun doPostMessage(...) {
var messageId: Long? = null
try {
messageId = messageRepository.insertSendingTextMessage(...)
val apiMessage = apiClient.postMessage(...)
messageRepository.updateSentMessageAndParents(apiMessage)
} catch (ex: Exception) {
if (messageId != null) messageRepository.updateMessageState(messageId, MessageState.ERROR)
throw ex
}
}
ursus
06/21/2019, 3:26 PMursus
06/21/2019, 3:26 PMkioba
06/21/2019, 3:36 PMmessageRepository
.insertSendingTextMessage(...)
.flatMap { messageId ->
apiClient.postMessage(...)
.flatMap{ apiMessage -> messageRepository.updateSentMessageAndParents(apiMessage) }
.onErrorResumeNext { error ->
messageRepository.updateMessageState(messageId, MessageState.ERROR) }
.flatMap{ Observable.error(error) }
}// ONLY if you want to trigger the error but My suggestion would be to return a Succes() / Error() sealed class.
}
.flatMap{ Observable.error(error) }
at the end is there only because when you catch an exception you also throw it again. but it is up to you if you want to keep it or not 🙂ursus
06/21/2019, 3:55 PMif (messageId != null) messageRepository.updateMessageState(messageId, MessageState.ERROR)
catch?insertSendingTextMessage
, right?kioba
06/21/2019, 3:58 PMinsertSendingTextMessage
fails, it never executes the inner part so the onErrorResumeNext { updateMessageState() }
never gets called.ursus
06/21/2019, 3:58 PMkioba
06/21/2019, 3:59 PM