rx-java

Rx: Combine ThrottleFirst and Sample operators

♀尐吖头ヾ 提交于 2020-05-13 04:19:25
问题 Given a source observable S, how can I ask RxJava / Rx to produce observable D, that: Emits first item from S without any delay Waits at least T seconds after emitting every item and before emitting next item L, where L is the last item emitted by S during the waiting period Emits the next item immediately after it appers in S, if S didn't produce any item during the waiting period T (from the point #2) Marble diagram: I thought to use: Sample operator, but it does not satisfy the requirement

Rx: Combine ThrottleFirst and Sample operators

旧街凉风 提交于 2020-05-13 04:18:47
问题 Given a source observable S, how can I ask RxJava / Rx to produce observable D, that: Emits first item from S without any delay Waits at least T seconds after emitting every item and before emitting next item L, where L is the last item emitted by S during the waiting period Emits the next item immediately after it appers in S, if S didn't produce any item during the waiting period T (from the point #2) Marble diagram: I thought to use: Sample operator, but it does not satisfy the requirement

Rx: Combine ThrottleFirst and Sample operators

岁酱吖の 提交于 2020-05-13 04:18:17
问题 Given a source observable S, how can I ask RxJava / Rx to produce observable D, that: Emits first item from S without any delay Waits at least T seconds after emitting every item and before emitting next item L, where L is the last item emitted by S during the waiting period Emits the next item immediately after it appers in S, if S didn't produce any item during the waiting period T (from the point #2) Marble diagram: I thought to use: Sample operator, but it does not satisfy the requirement

RxJava Return single, execute completable after

六眼飞鱼酱① 提交于 2020-05-11 04:40:28
问题 I'm trying to accomplish the following: Return some data as single, execute a completable after. The following code does not compile due to single.andThen(). The actions need to be executed in this order. val single = Single.create<String> { it.onSuccess("result") } val completable = Completable.create { println("executing cleanup") } val together = single.andThen(completable) together.subscribe( { println(it) }, { println(it) } ) 回答1: Use flatMap : single.flatMap(v -> completable.andThen

How can I replace inter thread communication using volatile variables with rxjava?

匆匆过客 提交于 2020-04-30 06:44:23
问题 I've got an application that does a lot of communication between threads by having one thread set a volatile variable on some object which another thread checks. I find this to be very error prone, and I want to try and replace it using RxJava bu there are some cases I can't figure out how to convert. The case I'm struggling with right now is where I have two threads, lets call one the controller and the other the measurer. The measurer's job is to record some quantity every 100ms. The

What are the ways to merge to Observables / Singles?

人盡茶涼 提交于 2020-04-30 02:00:09
问题 I have this code: public void testGetBlob() throws RequestException { TestData.getNewApplication().flatMap(testApplication -> { Client.initialize(testApplication.getAppId(), testApplication.getApiToken(), testApplication.getMasterKey()); assertNotNull(testApplication.getApiToken()); assertNotNull(testApplication.getAppId()); assertNotNull(testApplication.getMasterKey()); Entity entity = new Entity("Todo"); return entity.create(); }).flatMap(entity -> entity.setBlobProperty("text", "Hello

What are the ways to merge to Observables / Singles?

 ̄綄美尐妖づ 提交于 2020-04-30 01:58:56
问题 I have this code: public void testGetBlob() throws RequestException { TestData.getNewApplication().flatMap(testApplication -> { Client.initialize(testApplication.getAppId(), testApplication.getApiToken(), testApplication.getMasterKey()); assertNotNull(testApplication.getApiToken()); assertNotNull(testApplication.getAppId()); assertNotNull(testApplication.getMasterKey()); Entity entity = new Entity("Todo"); return entity.create(); }).flatMap(entity -> entity.setBlobProperty("text", "Hello

RxJava introduced Single<T>. How do I convert an Observable<T> to a Single<T>?

岁酱吖の 提交于 2020-04-29 07:18:07
问题 RxJava recently introduced Single. Is there a way to convert an already existing Observable (that's pretty much a Single) to a Single without modifying the source of the original observable? For example, I have an api service class with a method that returns an Observable - which is essentially fetching a User from a remote resource. Say I can't modify the service. I want to consume this elsewhere but return a Single. How do I do this? A pinch more background RxJava recently introduced the

RxJava introduced Single<T>. How do I convert an Observable<T> to a Single<T>?

落花浮王杯 提交于 2020-04-29 07:17:57
问题 RxJava recently introduced Single. Is there a way to convert an already existing Observable (that's pretty much a Single) to a Single without modifying the source of the original observable? For example, I have an api service class with a method that returns an Observable - which is essentially fetching a User from a remote resource. Say I can't modify the service. I want to consume this elsewhere but return a Single. How do I do this? A pinch more background RxJava recently introduced the

RxAndroidBle Multiple Characteristic Notifications and Read/Write

笑着哭i 提交于 2020-04-14 08:14:52
问题 I'm having issues setting up notifications on multiple characteristics. I've reviewed the documentation and many of the examples only cover very granular situations. My use case is as follows: 1. scan for devices 2. user selects device to connect to (with the connection persisting until the app is closed) 3. subscribe to notifications for many characteristics 4. read/write to either single characteristics at a time, and in some cases read/write to many characteristics at a time 回答1: I got it