filipradon
09/19/2019, 8:41 AM@Test
fun `assert observable fires only once ever`() {
val testObservable = Observable.just(true)
testObservable.test().assertValue(true)
testObservable.test().assertNoValues()
}
arekolek
09/19/2019, 11:16 AMval isRead = AtomicBoolean(false)
val testObservable = Maybe.fromCallable { true.takeUnless { isRead.getAndSet(true) } }.toObservable()
Akram
09/21/2019, 6:08 PMMohamed Ibrahim
09/22/2019, 11:16 AMMaciek
09/23/2019, 12:21 PMonNext
on subject
. Can someone explain why `subscribe`method on observable where you pass whole subject
object is not working the same way? Also what is happening with disposable from such subscribe
? Is it the same disposable when you make subscription on the subject
?blakelee
09/24/2019, 9:02 PMObservableEmitter.setDisposable(Disposables.fromAction {})
work the same as Observable.doOnDispose{}
?pteale
09/30/2019, 10:55 AMursus
10/02/2019, 3:23 AMSingle.fromCallable {
someBlockingCode()
}
Sam
10/03/2019, 6:48 PMMohamed Ibrahim
10/08/2019, 12:17 PMonComplete()
or onError()
get called, does the subscription got disposed and cleared from the memoryalexsullivan114
10/30/2019, 8:27 PMLiveDataReactiveStreams
library to bridge the two if that's what you're looking for: https://developer.android.com/reference/androidx/lifecycle/LiveDataReactiveStreamsivano
11/05/2019, 12:48 PMBoolean
as Flag in the viewModel, but Observable<Boolean>
and so on for everything because he claims that imperative and functional paradigms should not be used togheter. So I am in a situation where if I want to control a simple true false, have to make a PublishSubject
, start it with a value, and then bind it, while I think would be much more efficient to do a simple Boolean viewModel.isSomethingTrue
. Kotlin is not AFAIK a reactive functional language as clojure for instance, so I guess under the hood everytime I use RXJAVA I am going to build a lot on top of an Observable pattern a Boolean anyway! * Is reasonable and more performance effective to combine RXJAVA with ’Imperative” as I think, or I should bind evey single thing and make my Activity classess much more verbose as the architect is saying? *Mohamed Ibrahim
11/07/2019, 8:32 AMonError()
val testNulls = Observable.create<String> {
throw NullPointerException()//case 1
// it.onNext(null!!) // case 2
it.onNext("Ahmed")
}
ursus
11/11/2019, 5:01 PMupload
seem to be race-y, and not in the order of the listarekolek
11/14/2019, 8:01 AM.flatMap(::someFunction, false, 5)
what you want?Mohamed Ibrahim
11/14/2019, 8:10 AMAntónio Bastião
11/14/2019, 3:07 PMrequestData()
is called twice and how to avoid it?
Observable.just(Unit)
.delay(REPEAT_DELAY, TimeUnit.MILLISECONDS)
.repeat()
.async(job)
.subscribe({ requestData() },
{
Timber.e(it, "subscribeError")
}
)
yougin
11/15/2019, 11:07 AMObservable
, doOnUnsubscribe
is invoked upon unsubscribe (dispose) by each of them. Is there a way to wait until everyone unsubscribes?sanmi
11/18/2019, 5:19 PMam414
11/25/2019, 3:59 AMObservable<Integer> ob = Observable.timer(30,TimeUnit.SECONDS).just(1);
ob.subscribe(n-> System.out.println(n));
orafaaraujo
12/02/2019, 8:19 AMPublishSubject
to Flow
, or BroadcastChannel
or something more Kotlin-ish way?
Thank youSimon Kågedal Reimer
12/10/2019, 3:12 PMFlowable
and I would like to consume all events from it, but add a little delay between each events. How would I best do that?gregd
12/11/2019, 7:55 AMblakelee
12/12/2019, 7:47 PM@Test fun `test poll`() {
open class MyClient {
fun fetchItemFromServer(): Single<Boolean> = Single.just(true)
}
val testScheduler = TestScheduler()
val client = mock<MyClient>()
whenever(client.fetchItemFromServer())
.thenReturn(Single.just(false), Single.just(true))
val test = client.fetchItemFromServer()
.repeatWhen { it.delay(10, TimeUnit.SECONDS, testScheduler) }
.distinctUntilChanged()
.test()
testScheduler.advanceTimeBy(10, TimeUnit.SECONDS)
test.assertResult(false, true)
}
Ariana
12/27/2019, 5:31 PMMaybe.just(list)
.flatMapSingle { repository.getStuffList(id) }
.map { stuffList -> stuffList.filter { stuff -> list.contains(stuff) } }
.flatMapCompletable { stuffAfterFilter ->
secondRepository.doThing(stuffAfterFilter)
.doOnError { Completable.error(IllegalStateException("failure")) }
.andThen { repository.deleteStuff(stuffAfterFilter) }
}
.andThen(repository.getStuffList(id))
What’s the best way to have each call to repository.getStuffList(id)
return different items when they’re called?
Right now I’ve got order of operations setup in my test (which has worked in the past), but now the first time the method is called it’s returning stuffList2
instead of stuffList1
whenever(repository.getStuffList("id")).thenReturn(Single.just(stuffList1))
whenever(secondRepository.doThing(any())).thenReturn(Completable.complete())
whenever(repository.deleteStuff(any())).thenReturn(Completable.complete())
whenever(repository.getStuffList("id")).thenReturn(Single.just(stuffList2))
Am I on the right path here?Jason
01/10/2020, 1:51 AMfun getUserInfo() : Single<UserInfo>
fun save(token: Token) : Completable
fun initialize() {
getUserInfo()
.flatMap {
// Get token from UserInfo : val token = userInfor.getToken()
// Call save(token: Token) method to save data
}
.subscribeOn(<http://Schedulers.io|Schedulers.io>())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess = {
// HERE: Using UserInfo to do somtehing
},
onError = {
Log.d(it)
}
)
}
How to write code inside flatMap
block ? ( Or is there other operator suitable with this use case?)ossama
01/26/2020, 3:53 PMtoObservable()
on my completable, but nothing is emitted in onNext. The doc of the method Completable.toObservable()
says:
Returns an Observable which when subscribed to subscribes to this Completable and relays the terminal events to the subscriber.
I am using something like this
Completable.complete()
.toObservable<Any>()
.subscribe { }
iex
01/28/2020, 6:46 AMResult
as return type)?iex
02/03/2020, 9:25 AMDisposable
of a Single
around if you don't plan make it cancellable?iex
02/11/2020, 1:39 PMBehaviorSubject
but where the value is not optional?iex
02/11/2020, 1:39 PMBehaviorSubject
but where the value is not optional?kioba
02/11/2020, 4:02 PMBehaviorSubject.createDefault(1)
iex
02/11/2020, 5:40 PMvalue
on it and it returns the value, not an optional @kiobakioba
02/11/2020, 6:38 PMnull
.
Altho it works, Wouldn’t suggest the value usage. Sometimes i comes handy but on a longer terms it is a bad decision. Try to subscribe to the stream instead