reactive-programming

Is the 'Signal' representation of Functional Reactive Programming correct?

Deadly 提交于 2019-12-02 22:47:25
I have been researching FRP and found a bunch of different implementations. One model I have seen is one I will refer to as the 'Signal' representation. This essential combines Events and Behaviours into one entity. Firstly, a Signal is an object thats value is a Behaviour. Secondly, a Signal has an Event 'stream' that can be seen and operated on as a standard data structure (you can use 'each', 'map' and 'filter' etc on the Signal to define how Events are reacted to). For example I can do this (where 'time' is a Signal representation of time): time.each { t => print(t) } // every time there

How cancel task with retrofit and rxjava

不想你离开。 提交于 2019-12-02 20:37:56
I have rest api. @Get("/serveraction") public Observable<String> myRequest(@Query("Data") String data); I know, that okhttp has canceling functionality(by request object, by tag), but don't know how use it with retrofit and rxjava. What is the best way to realize canceling mechanism for network tasks with retrofit and rxjava? You can use the standard RxJava2 cancelling mechanism Disposable . Observable<String> o = retrofit.getObservable(..); Disposable d = o.subscribe(...); // later when not needed d.dispose(); Retrofit RxJava call adapter will redirect this to okHttp's cancel. RxJava1: https:

Reactive object bindings in a non-shiny context

流过昼夜 提交于 2019-12-02 20:35:34
Actual question How could you either approximate the reactive environment/behavior established by shiny functions or possibly even use these very functions in a non-shiny context in order to create "reactive" variables? Background I'm absolutely fascinated by the shiny framework and its underlying paradigms. In particular with respect to the established overall reactive environment. Just for the pure fun of it, I wondered if one could transfer this reactive programming paradigm to a non-shiny context - i.e. a regular R application/project/package or however you want to call it. Maybe think

How to 'wait' for two observables in RxJS

。_饼干妹妹 提交于 2019-12-02 19:58:26
In my app i have something like: this._personService.getName(id) .concat(this._documentService.getDocument()) .subscribe((response) => { console.log(response) this.showForm() }); //Output: // [getnameResult] // [getDocumentResult] // I want: // [getnameResult][getDocumentResult] Then i get two separated results, first of the _personService and then the _documentService . How can I wait for both results before call this.showForm() to finish an then manipulate the results of each one. Update: Oct, 2018 I previously suggested the use of zip method. However, since then I found myself using

Advantages of .NET Rx over classic events?

梦想的初衷 提交于 2019-12-02 18:56:28
.NET 4.0 beta 2 has introduced the IObservable and IObserver interfaces. What are the advantages compared to classic .NET events? Doesn't this solve the same problem? You can use IObservable as an event, replacing code that exposes events with properties of type IObservable, but that's not really the point. There are two important things to understand about IObservable: It unifies two concepts that we didn't know how to unify before : asynchronous operations (which typically return a single value) and events (which typically go on forever). It is composable . Unlike CLR events, IAsyncResult,

WebClient vs RestTemplate

最后都变了- 提交于 2019-12-02 17:58:31
As per spring 5: WebClient is an interface representing the main entry point for performing web requests. It has been created as a part of the Spring Web Reactive module and will be replacing the classic RestTemplate in these scenarios. The new client is a reactive, non-blocking solution that works over the HTTP/1.1 protocol Does that mean, we need to recode for the old applications using RestTemplate if we want to upgrade to Spring 5? Or there is some workaround to work with RestTemplate in Spring 5? No, RestTemplate will continue to exist(atleast for now). You don't have to replace it with

Benefits of having HTTP endpoints return Flux/Mono instances instead of DTOs [closed]

余生颓废 提交于 2019-12-02 17:33:15
I've watched Spring Tips: Functional Reactive Endpoints with Spring Framework 5.0 and read a little about spring reactor but I can't quite understand it. What are the benefits of having endpoints return Flux / Mono instances (jacksonified) instead of straight up dto objects (jacksonified), given that I've got netty and spring reactor active? I initially assumed that reactive streams would, in http request/response context, work more like websockets wherein the server pushes the data to the receiver with an open channel but this doesn't seem to be the case. Also what does netty actually do

Comparison of Java reactive frameworks [closed]

瘦欲@ 提交于 2019-12-02 17:07:56
I see many frameworks/libraries that claim that they can help build reactive applications in Java, such as: Akka, Vert.x, RxJava, Reactor, QBit, etc. They seem to have different approaches, features, pros, cons, etc. I could not find detailled comparisons. There is documentation about each of these framerwork, but it is not enough for me to understand the differences. What are the differences between the major Java reactive frameworks? And what are the application requirements that can drive the choice of a Java reactive framework? Thank you for your time. I'm working on RxJava and I did some

When to use RACReplaySubject vs. RACMulticastConnection?

别说谁变了你拦得住时间么 提交于 2019-12-02 16:49:24
Using ReactiveCocoa , there seem to be two ways to have subscribers receive the same values from a signal, rather than re-triggering whatever operation generates those values: Via RACReplaySubject or RACMulticastConnection. Here are the header docs for RACReplaySubject: A replay subject saves the values it is sent (up to its defined capacity) and resends those to new subscribers. It will also replay an error or completion. And for RACMulticastConnection: A multicast connection encapsulates the idea of sharing one subscription to a signal to many subscribers. This is most often needed if the

Correct way of throwing exceptions with Reactor

社会主义新天地 提交于 2019-12-02 16:47:05
I'm new to project Reactor and reactive programming in general. I'm currently working on a piece of code similar to this: Mono.just(userId) .map(repo::findById) .map(user-> { if(user == null){ throw new UserNotFoundException(); } return user; }) // ... other mappings This example is probably silly and there are surely better ways of implementing this case, but the point is: Is it wrong to use a throw new exception in a map block or should I replace this with a return Mono.error(new UserNotFoundException()) ? Is there any actual difference in these two ways of doing? Oleh Dokuka There are a