reactive-programming

Create infinite repeatable Observable from array

一曲冷凌霜 提交于 2019-12-11 03:44:47
问题 Let's say I have an array items I know I can create an observable from this array using Rx.Observable.fromArray(items) How do I create a lazily infinitely repeating observable from this (i.e.: repeating the items as long as they are being requested)? Tried Rx.Observable.fromArray(items).repeat() But this doesn't execute lazily and therefor locks up the browser. 回答1: You cannot do this with an Observable. You way want to look at using an Enumerable. The Enumerable flavor of Reactive Extensions

How to use vert.x-rx to create reactive client-server TCP communication

前提是你 提交于 2019-12-11 03:26:17
问题 I'm currently working on a project which requires TCP communication between an external system and an application which I will write (in Java). As we all know, this can easily be achieved using regular NIO. However, as part of this new project I'm working on, I have to use Vert.x to provide the TCP communication. Please refer to the image below: On the right, I have my application which runs as a TCP server waiting for a connection from the external system, on the left. I've read that to

R shiny isolate reactive data.frame

喜夏-厌秋 提交于 2019-12-11 01:25:27
问题 I am struggling to understand how isolate() and reactive() should be used in R Shiny. I want to achieve the following: Whenever the "Refresh" action button is clicked: Perform a subset on a data.frame and, Feed this into my function to recalculate values. The subset depends on a group of checkboxes that the user has ticked, of which there are approximately 40. I cannot have these checkboxes "fully reactive" because the function takes about 1.5 sec to execute. Instead, I want to give the user

How do I obtain a rolling buffer of the last two items emitted from a reactive stream?

南笙酒味 提交于 2019-12-11 00:33:26
问题 I have a stream that emits numbers x . What I want is dx (difference in x) so I need a rolling buffer which emits x_n and x_(n-1) so I can map to dx = x_n - x_(n-1) . In a marble diagram this would look like ... SOURCE --A------B------C--------D------F--G----- RESULT ---------AB-----BC-------CD-----DF-FG---- This would be handy for other operations like rolling averages etc. I have checked the operator docs but can't seem to find anything similar. sample is sort of close but is time dependent

Notification when ReactiveCommand completes

一曲冷凌霜 提交于 2019-12-11 00:26:40
问题 I'm trying to use ReactiveUI ReactiveCommands to switch on and off a gRPC stream that I've converted into an observable. The code shown below works to some extent - the connect button will cause the stream to connect, and I start receiving data in the onNext handler of the subscribe. The disconnect button does also disconnect the stream via the cancellation token. However, once the disconnect command is executed, I would also like to be notified so I can clear up some other state in the

Observable to batch like Lmax Disruptor

[亡魂溺海] 提交于 2019-12-10 23:55:45
问题 Those who are familiar with lmax ring buffer (disruptor) know that one of the biggest advanatages of that data structure is that it batches incomming events and when we have a consumer that can take advantage of batching that makes the system automatically adjustable to the load, the more events you throw at it the better. I wonder couldnt we achieve the same effect with an Observable (targeting the batching feature). I've tried out Observable.buffer but this is very different, buffer will

RxJs: how to get values emitted before we subscribe?

随声附和 提交于 2019-12-10 23:16:30
问题 With RxJs, once we start subscribe to an observable, we will start getting values once they are emitted, but how do I get all the values emitted by an observable before I've subscribed to it? 回答1: An observable is just a function that returns 0 or more values between now and the end of time. Like any other function it doesn't do anything before it's called (subscribed to). That being said, you can transform your observable to a hot observable by calling: // This makes the observable

How to solve this with Akka actors?

余生长醉 提交于 2019-12-10 23:15:22
问题 didn't know how to name this thread but will try to explain the problem in few lines. I have a command which need to calculate price for desired date range. To calculate it system needs to fetch the price for every day individually (DB, config, cache, it doesn't matter from where). My suggestion was to have one PriceRangeActor which will have a pool of DailyPriceActors and will send them commands like CalculateDailyPrice. But how to assemble all that data in PriceRanceActor? 1. Having some

How do I observe a signal and immediately receive a `next` event if it has already occured?

风格不统一 提交于 2019-12-10 22:57:22
问题 I'm trying to wrap an API call that initializes an object after a network request. I don't want the network request to happen for every new observer, so as I understand it, I shouldn't be using SignalProducer . However, by using a single Signal , only the first usage of it will receive a next event, while any newer subscribers will never receive the current value. How should I be doing this? I'm probably doing something fundamentally wrong with RAC. extension SparkDevice { static func

Unable to import 'Rx' to my Angular 2 application

泄露秘密 提交于 2019-12-10 21:38:55
问题 I am pretty new at Angular2. I am trying to learn it using a dummy app. I have recently gone through a tutorial on RxJS and got a basic hold on Observables (or atleast I assume so). Based on that, I have an idea of returning a list of users from my array in service as a stream. I intent to use interval for it and display a kind of lazy loading effect on screen. My intention is something like: getUsers() { return Rx.Observable.from(this.users); //want to add interval too on this } However, I