reactive-programming

Send big file over reactive stream

廉价感情. 提交于 2019-12-12 16:34:17
问题 Part of application I am writing requires transferring arbitrarily big (for this question I will assume 100-200 GB) files from client to server. Important thing, is that receiver (server) is not storing this file - it just read/examine stream and sends it to next point. Because at no point I need whole file, but expect multiple transfers at same time, I would like to minimize RAM usage and eliminate disk usage. I would like to process files in chunks of 1 MB. Right now, server uses Spring

Shiny R reactivevalues memory leak

…衆ロ難τιáo~ 提交于 2019-12-12 16:22:00
问题 I'm trying to understand why a cycling use of shiny's reactivevalues causes it to use more memory. The context is a user interface with the option to automate a given strategy. The example below is based on the St. Petersburg paradox. I appreciate that it may be better practice to place the entire automation process in a seperate function file but I would like to understand why the reactive object increases in size and if there is a more immediate work around. The example below will print out

RxJava zip with vararg observables

妖精的绣舞 提交于 2019-12-12 16:02:04
问题 When we know exactly how many observables we have with their exact types and we want to zip we do like this Observable<String> data1 = Observable.just("one", "two", "three", "four", "five"); Observable<String> data2 = Observable.just("one", "two", "three", "four", "five"); Observable<String> data3 = Observable.just("one", "two", "three", "four", "five"); Observable.zip(data1, data2, data3, (a, b, c) -> a + b + c); we use fixed argument functional interface which takes 3 arguments... and it

What RxJava operator to use to chain observables only under certain conditions

送分小仙女□ 提交于 2019-12-12 12:32:50
问题 I'm developing a whole application in RxJava/Android, trying to make the things the most Rx-way possible. I think I'm achieving what I wanted, but now I've encountered an issue that I'm sure that exists a better way to do it. It consists of: Get a Boolean from an Observable A: If it's true, you are done, return true. B: If it's false, make a request (call it firstRequest) and receive an Observable. A: The same, if it's true, you are done, return true. B: If it's false, then make another

Cross thread exception when using RX Throttle

こ雲淡風輕ζ 提交于 2019-12-12 11:15:52
问题 I am getting Invalid cross-thread access. When using RX Throttle Here is my code: yObs.SubscribeOnDispatcher() .DistinctUntilChanged() .Throttle(TimeSpan.FromMilliseconds(33)) .SkipWhile(y => !_isDragging) .Subscribe(y => { // Exception when trying to access image image.RenderTransform = new CompositeTransform() { TranslateY = -y }; _vm.UpdateContentDrag(y / image.ActualHeight * 100); }); But if I omit throttle everything works. As far as I understand Throttle uses thread pool so OnNext doesn

Angular 2 AsynPipe isn't working with an Observable

烈酒焚心 提交于 2019-12-12 11:06:36
问题 I'm getting the following error: EXCEPTION: Cannot find a differ supporting object '[object Object]' in [files | async in Images@1:9] Here's the relevant part of the template: <img *ngFor="#file of files | async" [src]="file.path"> Here's my code: export class Images { public files: any; public currentPage: number = 0; private _rawFiles: any; constructor(public imagesData: ImagesData) { this.imagesData = imagesData; this._rawFiles = this.imagesData.getData() .flatMap(data => Rx.Observable

RxJava only check the first response item with timeout

筅森魡賤 提交于 2019-12-12 10:34:04
问题 I see that ReactiveX (RxJava) has an operator timeout , which will apply to every item in a subscription stream. But I only want to check the very first response with a timeout and do not care about timeouts for the following responses. How can I implement this requirement elegantly with RxJava's operators? 回答1: Here is a more functional way of doing it. It's in Scala but should be transcribed to Java: val myTimeout : Observable[Nothing] = Observable timer (10 seconds) flatMap (_ =>

Reactive parallelization doesn't work

北战南征 提交于 2019-12-12 10:23:22
问题 Using project Reactor 3.0.4.RELEASE. Conceptually, should be same in RxJava as well. public Mono<Map<String, Boolean>> refreshPods(List<String> apps) { return pods(apps) .filter(this::isRunningAndNotThisApp) .groupBy(Item::getName) .flatMap(g -> g .distinct(Item::getIp) .collectList() // TODO: This doesn't seem to be working as expected .subscribeOn(Schedulers.newParallel("par-grp")) .flatMap(client::refreshPods)) .flatMap(m -> Flux.fromIterable(m.entrySet())) .collectMap(Map.Entry::getKey,

Streaming in slick/scala

拈花ヽ惹草 提交于 2019-12-12 08:41:43
问题 I'm looking at scala/slick streaming, and trying to understand how it works. Here is my test code val bigdata = TableQuery[BigData] val x = db.stream(bigdata.result.transactionally.withStatementParameters(fetchSize = 100)).foreach { (tuple: (Int, UUID)) => println(tuple._1 + " " + tuple._2) Thread.sleep(50)//emulating slow consumer. } Await.result(x, 100000 seconds) While the code is running I enabled postgresql query log to understand whats going under the hood. I see a re-query happening

Circular Dependencies with RxJS. Modeling spores

僤鯓⒐⒋嵵緔 提交于 2019-12-12 06:06:48
问题 I try to model some game with RxJS. but I found some troubles with circular dependencies. So, I simplified my game to a simple simulation(I left only 'move' action). You can find code below(I omitted some parts, you can find the repo here) const rx = require('rx') const math = require('mathjs') const _ = require('underscore') const FIELD_SIZE = 10 const ctx = require('axel'); let getInitialState = () => { return { size: FIELD_SIZE, people: [ { x: 0, y: 0 }, { x: 9, y: 9 }, { x: 5, y: 5 } ] }