reactive-programming

Spring 5 Web Reactive - Hot Publishing - How to use EmitterProcessor to bridge a MessageListener to an event stream

别来无恙 提交于 2019-12-07 04:49:51
问题 A sample project is located here: https://github.com/codependent/spring5-playground I would like to bridge a message received from a JMS queue into a Reactive Controller that would publish the messages as an event stream. I don't want the messages to be replayed, that is, if a message arrives and there isn't any subscriber I don't want them to be sent later when any subsbribes, so I am using an EmitterProcessor: @Component public class AlertEmitterProcessor { private Logger logger =

RxJava - How to stop (and resume) a Hot Observable (interval)?

本秂侑毒 提交于 2019-12-07 03:46:22
问题 I have the following Hot Observable: hotObservable = Observable.interval(0L, 1L, TimeUnit.SECONDS) .map((t) -> getCurrentTimeInMillis())) However, I can't find a good way to stop it. I was able to partially solve this using takeWhile and a boolean flag ( runTimer ): Observable.interval(0L, 1L, TimeUnit.SECONDS) .takeWhile((t) -> runTimer) .map((t) -> getCurrentTimeInMillis())) There are 2 things I don't like in this approach though: I must keep the flag runTimer around, which I don't want.

Debounce without initial delay

跟風遠走 提交于 2019-12-07 02:39:21
问题 Is there an operator in RxJS that debounces without delaying the "first event in a burst", but delaying (and always emitting) the "last event in a burst"? Something like this: ---a----b-c-d-----e-f--- after awesome-debounce(2 dashes) becomes: ---a----b------d--e----f while a normal debounce would be: -----a---------d-------f It's kind of a mix between throttle and debounce... 回答1: Hmmm, this is the easiest solution I can think of. The interesting part for you is the awesomeDebounce() function

RxJava/RxAndroid - handle multiple EditText changes

社会主义新天地 提交于 2019-12-07 00:21:11
问题 I have 3 EditText fields and I have created 3 observables for these fields. Observable<CharSequence> o1 = RxTextView.textChanges(field1); Observable<CharSequence> o2 = RxTextView.textChanges(field2); Observable<CharSequence> o3 = RxTextView.textChanges(field3); I want to enable a button when all these three fields has some value in it. user can enter values in any order in the fields. How can i do that? EDIT I used zip to achieve that. Observable<CharSequence> o1 = RxTextView.textChanges

Functional reactive programming — is Fay expressive enough? [closed]

耗尽温柔 提交于 2019-12-06 18:23:17
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . So I'm doing a fairly involved javascript/html client with lots of ajax calls and other involvements of callback-ism. I'm entertaining

How to make countdown timer with RxJS Observables?

我们两清 提交于 2019-12-06 18:16:23
问题 I'm struggling to create a countdown timer using Observables, the examples at http://reactivex.io/documentation/operators/timer.html do not seem to work. In this specific example the error related to timerInterval not being a function of the Observable returned from timer. I have also been experimenting with other approaches and the best I've come up with is: Observable.interval(1000).take(10).subscribe(x => console.log(x)); The problem here is it counts up from 0 to 10 and I want a countdown

Combining Observables when both change simultaneously

℡╲_俬逩灬. 提交于 2019-12-06 17:25:46
I am trying to integrate ReactiveX into my GUI using RxPY. This is a general ReactiveX question. Say I have a visualization that depends on multiple Observable streams using combine_latest(stream1, stream2, plot_function) . This works great when one Observable changes, like when the user modifies a value; the visualization updates using the new values. However, sometimes both Observables are updated simultaneously, like when the user loads data for both streams from a single file. Technically, one Observable will be updated before the other (whichever comes first in the import function). As a

RxJS distinctUntilChanged - object comparsion

試著忘記壹切 提交于 2019-12-06 17:06:04
问题 I have stream of objects and I need to compare if current object is not same as previous and in this case emit new value. I found distinctUntilChanged operator should do exactly what I want, but for some reason, it never emit value except first one. If i remove distinctUntilChanged values are emited normally. My code: export class SettingsPage { static get parameters() { return [[NavController], [UserProvider]]; } constructor(nav, user) { this.nav = nav; this._user = user; this

how to move one component to another component on button click in react?

徘徊边缘 提交于 2019-12-06 17:00:29
could you please tell me how to move one component to another component on button click in react ? I get the react-router.js from cdn .I don't know how to use this js ..I want to show second component on button click of first component` here is my code http://codepen.io/anon/pen/jVoZjW?editors=1010 class Abc extends React.Component { handle(){ alert('move to second component') } render (){ return (<div><h1>second</h1><button onClick={this.handle}>move to second page</button></div>); } } class Pqr extends React.Component { render (){ return (<div><h1>second</h1><button>click</button></div>) } }

Combining latest from an observable of observables

你离开我真会死。 提交于 2019-12-06 15:42:44
Suppose I have a set of URIs that I am monitoring for availability. Each URI is either "up" or "down", and new URIs to monitor may be added to the system at any time: public enum ConnectionStatus { Up, Down } public class WebsiteStatus { public string Uri { get; set; } public ConnectionStatus Status { get; set; } } public class Program { static void Main(string[] args) { var statusStream = new Subject<WebsiteStatus>(); Test(statusStream); Console.WriteLine("Done"); Console.ReadKey(); } private static void Test(IObservable<WebsiteStatus> statusStream) { } } Now suppose in Test() I want to