reactive-programming

Is there a way to subscribe an observer as async

余生颓废 提交于 2019-12-01 01:24:11
Given a synchronous observer, is there a way to do this: observable.SubscribeAsync(observer); And have all methods on the observer called asynchronously or is that something I have to handle when creating the observer? meilke You might want to look into ObserveOn and SubscribeOn ( more information and even more information ). If you need to call an async method when the stream spits out a new value, the most common solution you will find is to use SelectMany . The problem is that this doesn't wait for the method to finish, causing any tasks created by SelectMany to run in parallel. Here's what

How to create a Spring Reactor Flux from a ActiveMQ queue?

五迷三道 提交于 2019-12-01 00:24:30
问题 I am experimenting with the Spring Reactor 3 components and Spring Integration to create a reactive stream (Flux) from a JMS queue. I am attempting to create a reactive stream (Spring Reactor 3 Flux) from a JMS queue (ActiveMQ using Spring Integration) for clients to get the JMS messages asynchronously. I believe that I have everything hooked up correctly but the client does not receive any of the JMS messages until the server is stopped. Then all of the messages get "pushed" to the client a

Simple way to get the current value of a BehaviorSubject with rxjs5

混江龙づ霸主 提交于 2019-11-30 21:26:47
问题 Previously in rxjs4 there was a method in the BehaviorSubject called: getValue() (doc here). This method does not exist any more in rxjs5 . So the only solution that I found to get the value of a BehaviorSubject was: let value; myBehaviorSubject.take(1).subscribe( (e) => value = e ); This code run synchronously (I do not exactly understand why, but it does ...) and get the value. It work, but it's not as clean as it could be if getValue() was present: let value = myBehaviorSubject.getValue();

In Shiny apps for R, how do I delay the firing of a reactive?

孤人 提交于 2019-11-30 20:39:45
I have a selectizeInput in my Shiny app. It is in multiple-select mode, so the user can specify more than one selection. However, the reactives that depend on the selectizeInput get fired every time a selection is added. Suppose that the user intends to select A , B and C . Currently, my app will do it expensive computations for the selections A , A, B and A, B, C , when only the last is required. The best way I can think to solve this is to delay the firing of the selectizeInput by a second or so to give the user a chance to enter all of the selections. Each new selection should set the timer

Make Http call using ReactiveX for Java

风流意气都作罢 提交于 2019-11-30 19:39:30
I am new to ReactiveX for Java and I've the following code block that make external http call but it is not async. We are using rxjava 1.2, and Java 1.8 private ResponseEntity<String> callExternalUrl(String url, String json, HttpMethod method) { RestTemplate restTemplate; HttpEntity request; request = new HttpEntity(jsonContent, httpHeaders); return restTemplate.exchange(url, httpMethod, request, String.class); } I've the following code block I found online but I couldn't totally understand it and how I can apply it to my code base. private RxClient<RxObservableInvoker> httpClient; public <T>

Using Reactive extension (Rx) for MSMQ message receive using async pattern (queue.BeginReceive,queue.EndReceive)

喜夏-厌秋 提交于 2019-11-30 19:17:07
I have been using Rx for a while now for Events on my projects and dedicatedly for Socket programming and the good part is its doing well. Managing my code, performance advantage and much better to execute and interpret. Lately I have to modify my project's process flow where i need to dump all the incoming data (from socket operations) into queues ( using MSMQ implementation as decided for queueing ). As MSMQ provides async call for dequeing messages from the queue (but in an wierd pattern). I have been struggling to use Rx for this purpose now, but enable to do so. Question : Can some one

How apply pagination in reactive Spring Data?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 19:16:41
In Spring Data, we have PagingAndSortingRepository which inherits from CrudRepository . In reactive Spring Data, we only have ReactiveSortingRepository which inherits from ReactiveCrudRepository . How could we make pagination in a reactive way ? Will we able to make this in future with ReactivePagingAndSortingRepository for instance? Reactive Spring Data MongoDB repositories do not provide paging in the sense of paging how it's designed for imperative repositories. Imperative paging requires additional details while fetching a page. In particular: The number of returned records for a paging

How to partition (GroupBy) a stream and monitor absence of elements in Rx within some time periods?

若如初见. 提交于 2019-11-30 17:56:43
问题 For the few previous days I have been trying to compose an Rx query to process a stream of events from a source and check absence of some IDs. The absence is defined so that there are a series of time windows (e.g. on all days from 9:00 to 17:00) during which there should be at maximum of, say, twenty minutes without an ID occurring in the stream. To further complicate matters, the time of absence should be defined per ID. For instance, assuming three kinds of events A, B and C appearing in a

Read continous bytestream from Stream using TcpClient and Reactive Extensions

北战南征 提交于 2019-11-30 17:07:14
Consider the following code: internal class Program { private static void Main(string[] args) { var client = new TcpClient(); client.ConnectAsync("localhost", 7105).Wait(); var stream = client.GetStream(); var observable = stream.ReadDataObservable().Repeat(); var s = from d in observable.Buffer(4) let headerLength = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(d.ToArray(), 2)) let b = observable.Take(headerLength) select b.ToEnumerable().ToArray(); s.Subscribe(a => Console.WriteLine("{0}", a)); Console.ReadLine(); } } public static class Extensions { public static IObservable<byte>

How to collect paginated API responses using spring boot WebClient?

荒凉一梦 提交于 2019-11-30 16:03:40
I have a paginated response from an URL, I want to keep on hitting the next page URL which I get from the previous response and keep on collecting items till I don't have a "nextPage" URL in my response. How to achieve this in a reactive way using spring boot WebClient from WebFlux with out blocking? Request1: GET /items response: { items: [...] nextPage: "/items?page=2" } Request2: GET /items?page=2 response: { items: [...] nextPage: "/items?page=3" } Request3: GET /items?page=3 response: { items: [...] nextPage: null } Here I have created mock urls https://karthikdivi.com/apps