FAQ Database Discussion Community


How do I extract the last value from an Observable and return it?

java,reactive-programming,rx-java
I'm doing some more RxJava experiments, mostly trying to figure out design patterns that would work for my business. I created a simple flight tracking application that tracks multiple flights, and reacts accordingly when a flight moves. Suppose I have a Collection<Flight> with Flight objects. Each flight has an Observable<Point>...

How does SequenceEqual work in Reactive Extensions

c#,.net,reactive-programming
I have a hard time to figure out how the SequenceEqual works in Reactive Extensions version 2.2.5 Below is the code var subject1 = new Subject<int>(); var subject2 = new Subject<int>(); IObservable<bool> sequenceEqual = subject1.SequenceEqual(subject2); subject1.OnNext(5); subject1.OnNext(3); subject2.OnNext(1); subject2.OnNext(4); //This will be notified if the two sequences completed sequenceEqual.Subscribe(b =>...

How would I cancel a click event if it was following a drag event using Bacon.js?

javascript,reactive-programming,frp,bacon.js
So I have some event streams: let mouseUps = $(window) .asEventStream('mouseup'); let mouseDowns = $(window) .asEventStream('mousedown'); let mouseMoves = $(window) .asEventStream('mousemoves'); let drags = mouseDowns .flatMapLatest(() => mouseMoves.takeUntil(mouseUps)); let clicks = $(window) .asEventStream('click') .onValue(() => doThing()); I'd like to ignore clicks that get triggered right after a drag ends. I...

Can functional reactive programming (FRP) be expressed using monads?

haskell,functional-programming,monads,reactive-programming
I've been reading up on Functional Reactive Programming, and though I have not used monads extensively in any language, I can't help but see them everywhere in the FRP design. This question's answers have some fantastic descriptions of what functional reactive programming is, and I won't attempt to replicate that...

Asynchronous RestAPIs with RxJava/Jersey2. Threading questions?

java,asynchronous,jersey-2.0,reactive-programming,rx-java
We are in the process of prototyping a REST API using reactive programming. As shown in the diagram, we keep 3 layers same as we used in our previouse sync API designs ; http://oi59.tinypic.com/339hhki.jpg API Layer implemented using Jersey2 which will process request/deserialize JSON and handover to Service Layer. Service...

Split Rx Observable into multiple streams and process individually

reactive-programming,rx-java,rxjs
Here is a picture of what I am attempting to accomplish. --a-b-c-a--bbb--a split into --a-----a-------a --> a stream ----b------bbb--- --> b stream ------c---------- --> c stream Then, be able to a.subscribe() b.subscribe() c.subscribe() So far, everything I have found has split the stream using a groupBy(), but then collapsed everything...

how to solve type issues with Moment t in reactive-banana?

haskell,reactive-programming,frp,reactive-banana
I'm trying to write a function like so: module Main where import Reactive.Banana import Reactive.Banana.Frameworks main = putStrLn "hello world" type MIDIMessage = (Int, Int, Double) startRBMidi f = do (addHandler, fire) <- newAddHandler :: IO (AddHandler MIDIMessage, Handler MIDIMessage) let networkDesc = do emidi <- fromAddHandler (addHandler :: AddHandler...

RxJS: Producer-consumer with abort

javascript,reactive-programming,rxjs,reactive-extensions-js
I've got a special producer consumer problem in RxJS: The producer slowly produces elements. A consumer is requesting elements and often has to wait for the producer. This can be achieved by zipping the producer and the request stream: var produce = getProduceStream(); var request = getRequestStream(); var consume =...

How can I subscribe to a one-time signal and conditionally initiate a secondary signal without having the original signal fired twice?

ios,objective-c,reactive-programming,reactive-cocoa
I would like to subscribe to a signal of one web operation and have it conditionally initiate a secondary web operation. The code I have put together looks a little like this: RACSignal *asyncWebAPI = [self asyncWebAPI]; @weakify(self) [asyncWebAPI subscribeNext:^(RACTuple *tuple) { @strongify(self) NSArray *foo = tuple.first; [self.bar addObjects:foo]; self.baz...

How to serve reactive ByteChunks in Play Framework (Java) v2.4.x

java,playframework,playframework-2.0,reactive-programming
I have a working code base that serves Chunks<byte[]> wrapped in an HTTP status 206. The code streams an .mp3 file to the browser. public class ChunksController extends Controller { private static byte[] song; private static RangeWrapper range; private static Chunks<byte[]> chunks; @With(MP3Headers.class) public static F.Promise<Result> handler() { return F.Promise.promise(new...

Creating a filterable list with RxJS

javascript,functional-programming,reactive-programming,rxjs,reactive-extensions-js
I'm trying to get into reactive programming. I use array-functions like map, filter and reduce all the time and love that I can do array manipulation without creating state. As an exercise, I'm trying to create a filterable list with RxJS without introducing state variables. In the end it should...

Meteor template not updating when template helper re-runs

meteor,reactive-programming,meteor-autoform,meteor-helper
I am trying to make a custom form wizard that will contain different autoform steps based on certain conditions. A simplified meteorPad example is linked below. When the reactive data source(session variable) changes the reactive computation(template helper) runs, confirmed by console output. The template, however, is not updated and still...

R Shiny - set reactive width of a plot output

plot,shiny,reactive-programming,weight
I am filtering a tbale and a heat-map simultaneously. During filtering, the width of the table is changing such that width of particular columns remains the same. Width of the heat-map remains the same during filtering. I want the heat-map to change its weight in the same way as the...

How to merge two streams (without nulls) and apply conditions on pairs?

reactive-programming,rxjs,reactive-streams
Consider I have two streams of data, is there a way to merge them and apply conditions on data between these two streams? For example Stream A : A, B, C, D.... Stream B : -, A, -, -.... Composed : (A,-),(B,A),(C,-),(D,-).... How to get composed stream above using rxjs?...

Checking for nil model using reactive cocoa?

reactive-programming,reactive-cocoa
I was wondering what the approach for checking for nil values with reactive cocoa is. I would assume I could create a signal like so. // Turn state check into a signal to activate the rest RACSignal* modelSignal = [self checkIfModelIsValid:self.model]; [[modelSignal then:^RACSignal *{ return [self obtainImageSignal]; // Always need...

Never running stream Bacon.js. Callback never calls

node.js,reactive-programming,frp,bacon.js
I am trying to use Bacon stream as never ending loop but it doesn't work. var Bacon = require('baconjs'); var INTERVAL = 300; var tickStream = Bacon.interval(INTERVAL); var isMaster = tickStream.flatMap(function() { console.log('I never see the message'); return Bacon.once('some value'); }); Why don't I see anything in console? How can...

RxJava: what is difference between callbacks in doOnError('callback') and subscribe(*, 'callback')

java,reactive-programming,rx-java
In my last project, I use rxJava and I realize that observable.doOnError('onErrorCallback').subscribe(action) and observable.subscribe(action, 'onErrorCallback') behave in different ways. Even from docs it's not obvious for me what's exactly the difference between them and when I should use first and second variant.

Dynamic calculated values in meteor templates

javascript,meteor,reactive-programming
I am trying to grasp something that I'm sure is pretty basic in meteor, i.e. using reactive calculated values. Here is a simple example of the sort of thing I am trying to acheive. The code doesn't work, but it looks something like what I would expect might work. I...

Signal of Signals ? Reactive Cocoa

objective-c,reactive-programming,reactive-cocoa
I am trying to understand this piece of code and why it returns a signal of signals. [[[self.signInButton rac_signalForControlEvents:UIControlEventTouchUpInside] map:^id(id x) { return [self signInSignal]; }] subscribeNext:^(id x) { NSLog(@"Sign in result: %@", x); }]; From what I understand the UIControlEventTouchupInside returns a next signal which contains the UIButton when...

NodeJS Streams v.s. Observables

javascript,node.js,reactive-programming,rxjs,bacon.js
After learning about Observables, I find them quite similar to NodeJS streams. Both have a mechanism of notifying the consumer whenever new data arrives, an error occurs or there is no more data (EOF). I would love to learn about the conceptual/functional differences between the two. Thanks!...

How wait observable result from independent components in rxjava

reactive-programming,rx-java
I have two observables. First - get session from internet or from cache; Observable<SessionKey> getSession = getSessionFromInternetOrCache(); Second - call to server api, using session Observable<MyResult> apiCall = getSession.flatMap(session -> { return myApi.getResult(session); }) Problem, that I have several independent components (gui). They are starting in parallel. apiCall also started...

How to add a method to Observable trait?

scala,reactive-programming,observable,rx-scala
I would like to add a method to the Observable class. What I have done so far was: object Extension { implicit class ObservableExtensions(obs: Observable[Double]) extends Observable{ def fakeMethod (alpha: Double): Observable[Double] = { obs .map(v => v+alpha) } } } But I get: Error: trait Observable takes type parameters...

Why is my RxJava observable not firing off subscribers?

java,multithreading,asynchronous,reactive-programming,rx-java
I'm messing around with RxJava and I want to stream a thousand consecutive integers. Then I want to asynchronously split them into odd and even streams, and then print them asynchronously. However, I'm getting nothing printed out or at least very partial output. What am I missing? Did I schedule...

How can I modify an IObservable such that I collect characters until there have been no characters for a period of time?

c#,system.reactive,reactive-programming
I would like to write an Rx query that takes an IObvservable<char> and produces an IObservable<string>. The strings should be buffered until there have been no characters produced for a specified time. The data source is a serial port from which I have captured the DataReceived event and from that...

Subscribe on RxJava observable multiple times

java,reactive-programming,rx-java,observable
I have a question about RxJava Observable. For example, I have an Retrofit interface, which returns me Observable. I need to do something with this stream of Video. Here is code for downloading Videos and saving it's into list: API.getVideoListObservable() .doOnError(t -> t.printStackTrace()) .map(r -> r.getObjects()) .doOnNext(l -> VideoActivity.this.runOnUiThread(() ->...

Delay items emission until item is emitted from another observable

reactive-programming,rx-java
Playing with RxJava now and stumbled upon the following problem: I have 2 different streams: Stream with items Stream (with just 1 item) which emits transformation information for the first stream. So essentially I have stream of items and I want all those items to be combined with that single...

React JS: Explanation of this.props.items.map feature

javascript,html5,reactjs,reactive-programming
I am using React JS for Rendering the HTML content. The issue is I am not able to understand particular section of code what it does. If you can see a basic sample of a Todo List from the below link http://facebook.github.io/react/ <script type='text/jsx'> /** @jsx React.DOM */ var TodoList...

RxJava: Find out if BehaviorSubject was a repeated value or not

java,android,reactive-programming,rx-java
I'm making an Android interface that shows some data fetched from the network. I want to have it show the latest available data, and to never be empty (unless no data has been fetched at all yet) so I'm using a BehaviorSubject to give subscribers (my UI) the latest available...

How use multiple observable's results in subscriber

reactive-programming,rx-java
To be precise, here is an simple example(In real world, both observables are long running task): Observable<String> city = Observable.just("Moscow"); //here i get hashcode based on result from city Observable<Integer> hashCodeFromCity = city.flatMap( new Func1<String, Observable<Integer>>() { @Override public Observable<Integer> call(String s) { return Observable.just(s.hashCode()); } }); hashCodeFromCity.subscribe(new Action1<Integer>() {...

Merge implemented as flatMap

javascript,reactive-programming,rxjs,reactive-extensions-js
Theoretically it should be possible to implement any RxJS operator (except just() and flatMap()) through flatMap(). For instance map() can be implemented as function map(source, selector) { return source.flatMap(x => Rx.Observable.just(selector(x))); } How to implement merge() through flatMap()? (avoiding mergeAll() too, of course)...

What is the difference between flatmap and switchmap in RxJava?

reactive-programming,rx-java
The rxjava doc definition of switchmap is rather vague and it links to the same page as flatmap. What is the difference between the two operators?

RxJS error handling

javascript,error-handling,reactive-programming,rxjs
I've got an issue with RxJS swallowing errors. So in my case I've got something like this: function funcThatThrowsError(fn, ..args) { return fn.bind(fn, ...args); } function fetchItems() { Observable.fromPromise( reqwest({ url: `${API_ROOT}${url}`, method, data, contentType: "application/json" }) ).map(funcThatThrowsError(null, "someValue")) } const observableA = fechItems(); const observableB = ... ; Observable...

How do I recurse in RxJava while only using a single thread?

java,multithreading,recursion,reactive-programming,rx-java
I had some working recursion code in my RxJava-based network stack for flatMapping the HTTP body string file listing into an Observable of custom POJOs representing the files. However, I was using .scheduleOn(Schedulers.newThread()), which uses multiple new threads to do the work. I just found out one of the devices...

Switching streams in RX: Sodium's equivalent of merge and switch in RX

c#,system.reactive,reactive-programming,sodium
How can the television channel problem as explained in this talk at 31th minute be solved by RX ? The problem expressed in Rx is as follows: The are two television channels (channel1 and channel2) which transmit a stream of images, plus a stream of fuzz which represents no channel...

How do I convert a ListView SelectedItem into an IObservable?

c#,xaml,listview,system.reactive,reactive-programming
This may be a remedial question, but my research is spinning me in circles right now (especially as a Java developer) and looking at several different Rx wrapper libraries. All I want is to take a ListView<MusicNote>.SelectedItem and wrap it into an IObservable, emitting a stream of the current single...

RxJava - How to keep observing an object until onError() / unsubscribing

java,asynchronous,reactive-programming,rx-java,observable
I need to observe a list of objects and emit an event as soon as there is a new object in the list. Like a client - server application where the client adds content to the list and the server emits the newly added content to all the clients registered...

ReactiveCocoa : Chain a signal with a repeating signal

ios,reactive-programming,reactive-cocoa,racsignal
Using ReactiveCocoa, how can I chain a signal from a repeating one? I would like to do something like this: Every 5 seconds, I run a network request. For this purpose, I created a repeating signal RACSignal *each5SecondSignal = [[[RACSignal interval:5 onScheduler:[RACScheduler mainThreadScheduler]] take:1] concat:[RACSignal 5 onScheduler:[RACScheduler mainThreadScheduler]]]; and a...

I have a chain of Rx.Subjects (A->B->C->A), but the final step is not working

javascript,system.reactive,reactive-programming,rxjs,reactive-extensions-js
Live example. I'm completely new to Rx*. I'm trying to create a reactive version of MVC using RxJS for my thesis. It's loosely based on https://github.com/staltz/mvi-example I probably should've studied RxJS more before starting to code, but I've realised I usually learn the best by just jumping to the deep...

Reactive Extensions Buffer Executes EveryTime irrespective of TimeSpan or count

c#,wpf,system.reactive,reactive-programming
I am creating and Search Text and want my application to perform search every 2 seconds or when there are at least 3 characters in the textbox. I am trying to use Reactive Extension's buffer or throttle to achieve the same. But I might not be clear about how these...

Never ending stream with Baconjs

javascript,node.js,redis,reactive-programming,bacon.js
I have a simple script which just take all values from Redis list and print them to console. var redis = require("redis"), client = redis.createClient(); Bacon = require('baconjs'); Bacon.repeat(function(){ return Bacon.fromNodeCallback( client, 'lpop', ['errors'] ); }) .takeWhile(function(val) {return val !== null;}) .fold( [], function(acc, next) { acc.push(next); return acc; }...

RxJava observables not emitting events

android,retrofit,reactive-programming,rx-java,observable
My android application has a FeedDetailFragment that displays Feed details. A feed has basic information and metadata, which are retrieved through two separate calls to the server. The server interface is filled in with Retrofit. I have implemented something that, to my novice Rx knowledge, looks logical. However, as you...

Java -Reactive Programming vs Event Listener [duplicate]

java,reactive-programming
This question already has an answer here: Advantage of Functional Reactive Programming over event-listeners 2 answers How the Reactive Programming differs from calling a function in Event listener (mouse, key), because both are kind of asynchronous event stream so whats the advantage of Reactive over traditional Event listeners calls?...

How to implement observeLatestOn in RxJava (RxScala)?

scala,reactive-programming,rx-java
I'm trying to implement the ObserveLatestOn operator in RxJava (actually, RxScala). This operator is useful, when we've got a fast producer and a slow subscriber, but the subscriber doesn't care about any items lost while it was consuming an item. A marble diagram: --1---2---3----------5------6--7-8-9------| --1=========>3===>---5=======>6======>9==>| The = character represents a...

How cancel task with retrofit and rxjava

retrofit,reactive-programming,rx-java,okhttp
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?...

C# .NET Rx- Where is System.Reactive?

c#,.net,system.reactive,reactive-programming
I have an intensive Java background so forgive me if I'm overlooking something obvious in C#, but my research is getting me nowhere. I am trying to use the reactive Rx .NET library. The compiler is not complaining about the IObservable but it is with the call to the zip...

What would make a Meteor app stop scrolling?

meteor,reactive-programming
Any browser. All other functions operate as normal. I can traverse routes, open modals, dropdowns, manipulate collections... everything works. But at some point, the browser will no longer scroll. In any view. Unless I refresh the browser window. Then scrolling goes back to normal. What might cause this? Why does...

filtering based on the last two current values in java rx

java,filter,reactive-programming,pair
I'm trying to build a simple application using java reactive extensions. I have two streams that emits temperature values continuously, I want to detect and filter out spikes of sensed temperature that could be errors, for doing so I need to take account of the precedent value too so that...

Functional reactive operator for custom filter based on another Observable

javascript,reactive-programming,rxjs,bacon.js
For fun and to learn I'm trying to implement an undo system in my app using functional reactive programming. I have a stream of state changes, which need to be saved onto the undo stack. When the user clicks undo, I take a value from the stack and update application...

Stopping all subsequent calls to subscribe in reactive extensions

c#,system.reactive,reactive-programming
I am replacing some of my previously written code with reactive extensions. Previously I was using File.ReadAllLines(FileName) and then loop through all the lines of files and in this loop at some point, I break from the loop and perform some operation on the processed records(which now I want to...

Play-Framework 2.3.x: Unable to send emails using plugin “play-mailer”

scala,email,reactive-programming,playframework-2.3
I am using play-framework 2.3.x and scala 2.11.4. When integrate play-mailer for sending and emails from my application, there is nothing happen. In the logs there are no exception produces and no return values are available. Following is email properties: smtp.host = "smtp.gmail.com" smtp.port = 25 smtp.user = "[email protected]" smtp.password...

Transform RxJava observable's error into another observable and swallow success

retrofit,reactive-programming,rx-java,observable
How do I transform observable's error to another observable? I am trying to implement algorithm showed on scheme below: I am using a tutorial named Grokking RxJava to start my learning and found that flatMap operator can convert one Observable returning by Retrofit into another which allows me to do...

buffer while processing items

c#,.net,system.reactive,reactive-programming
I have an event that fires regularly. Let's assume that processing the event takes ~1s. Instead of waiting 1s for each received event I want to accumulate events until the last processing is done. When processing is done I want to proces the event data I received during the last...

RxJava Bakcpressure (Fast producer slow consumer)

java,android,reactive-programming,rx-java
i have execution method which does some time consuming network calls on io thread example /** * network call * @param value * @return */ private Observable<Integer> execute(final int value) { return Observable.create(new Observable.OnSubscribe<Integer>() { @Override public void call(Subscriber<? super Integer> subscriber) { try { Thread.sleep(500); } catch (InterruptedException e)...

React: Will a state change cause an entire component to be redrawn?

javascript,reactjs,reactive-programming
I'm creating a form in react that has conditional flow. For example two input fields might be hidden when some select option is chosen. Is it a good idea to create states based on the select options and make the visibility of the input elements to depend on the current...

Does rxjava with couchbase offer value for non-bulk opertions

java,couchbase,reactive-programming,rx-java
The new Couchbase SDK makes bulk operations easier to use and more performant use rx-java. But is there any value to using rx for operations on single values? If we look at a simple CAS / insert operation, ie if the value exists do a cas else do an insert...

RxJava- performing a peek() or void operation within an Observable chain?

java,reactive-programming,rx-java
Java 8 lambda streams have a peek() operator which allows you to execute a void operation on each item. This is typically used for debugging, but it also is a nice way to cheat and kick off a void operation without mapping to something. Is there an equivalent to this...

Execute OnNext in parallel but sync subscription with UI thread

c#,.net,winforms,system.reactive,reactive-programming
given a Subject like this: var input = new Subject<int>(); and subscribers like this: var observer1 = input .Subscribe(ev => { Thread.Sleep(1000); listBox.Items.Add("o1: " + ev.ToString()); }); var observer2 = input .Subscribe(ev => { Thread.Sleep(1000); listBox.Items.Add("o2: " + ev.ToString()); }); how can I tweak it so that when I do...

Can RxJava reduce() be unsafe when parallelized?

java,multithreading,reactive-programming,rx-java
I want to use the reduce() operation on observable to map it to a Guava ImmutableList, since I prefer it so much more to the standard ArrayList. Observable<String> strings = ... Observable<ImmutableList<String>> captured = strings.reduce(ImmutableList.<String>builder(), (b,s) -> b.add(s)) .map(ImmutableList.Builder::build); captured.forEach(i -> System.out.println(i)); Simple enough. But suppose I somewhere scheduled the...

What technologies were used to produce this site?

javascript,html5,design,reactive-programming
I am planning to create a reactive theme for a website. I have looked into some tools like Adobe Animate for producing HTML5 reactive images. I came across the design on the https://www.playframework.com/ website. As you scroll the images change, there's some kind of reactive animation going on. What do...

RxJava- No access to Observable's subscribers?

java,monads,reactive-programming,rx-java
I learned it is undesirable to use Subjects in reactive programming although I found them highly convenient. But I understand they can be abused. So I tried to create an infinite Observable<ImmutableMap<Integer,ActionProfile> that needs to publish a new ImmutableMapevery time refresh() is called. I also have a forKey() method that...

How to create a job that runs at a fixed interval in RxJava?

reactive-programming,rx-java
I'm trying to create a task that will on a regular basis query my database write all the results in an other state and i'd like to do this using RxJava. I'm using RxJava-JDBC to query my database. Here's what the code looks like: final Database db = Database.from(url); db...

How cancel network request in retrofit and rxjava

retrofit,reactive-programming,rx-java
I have a multiple buttons; When I press new button, previous(with another button) running request should be interrupted and new runs. How to realize it? for (button : Buttons) { button.setOnClickListener(b -> networkApi.getLongContentFromUrl(url) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Subscriber<JsonElement>() { @Override public void onCompleted() {} @Override public void onError(Throwable e) { } @Override...

Reactive Extensions (Rx) - sample with last known value when no value is present in interval

c#,.net,system.reactive,reactive-programming
I have an observable stream that produces values at inconsistent intervals like this: ------1---2------3----------------4--------------5--- And I would like to sample this but without any empty samples once the a value has been produced: ------1---2------3----------------4--------------5----- ----_----1----2----3----3----3----4----4----4----5----5 I obviously thought Replay().RefCount() could be used here to provide the last known value to...

From IObservable to Task

task-parallel-library,system.reactive,reactive-programming,observable
So the case is this. Suppose somewhere I am filling a Collection. Each time an element is added, an IObservable calls OnNext for its subscribers. Now, there will be a point where the collection will be filled. (I was reading something and I finished reading .. whatever). At that point,...

How to chain signals in a proper way with Reactive Cocoa?

ios,objective-c,reactive-programming,reactive-cocoa
I'm using ReactiveCocoa in a new iOS app. I'm new to reactive programming so I'm still trying to understand what's the proper way to chain signals. Right now I have the following flow for the "login with Twitter" button. The ALTUserManager class has the following method for managing the whole...

HashMaps vs Reactive Programming

java,monads,reactive-programming,rx-java
I am starting to embrace reactive programming a bit more, and I'm trying to apply it to my typical business problems. One pattern I often design with is database-driven classes. I have some defined unit class like ActionProfile whose instances are managed by an ActionProfileManager, which creates the instances off...

RxJava zip with vararg observables

java,reactive-programming,rx-java
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,...

How can I make an IObservable from a queue, so that the sequence doesn't end when the queue is empty?

c#,system.reactive,reactive-programming
I'm working on something that uses Reactive Extensions for .NET (Rx) and I want to have a sequence that takes its input from a queue (or similar). I've tried doing this: static readonly Queue<DeviceTransaction> TransactionQueue = new Queue<DeviceTransaction>(); //... var observableTransactionSource = TransactionQueue.ToObservable(); //... observableTransactionSource.Subscribe(transactionObserver); It works up to a...

RxJava- Placing several Observable values in a static body of text?

reactive-programming,rx-java
I have heard several reactive programming folks say "don't break the monad, just continue it". I see the merit in this. There are still certain instances I'm confused about, especially when the Observable is finally consumed or subscribed to. This is even more confusing when several observables have to be...

Reactive programming - value is greater than X for N seconds

javascript,reactive-programming
I have a stream randStream which emit random value every half second and boolStream which converts value from randStream into boolean. let randStream = Kefir.fromPoll(500, () => Math.random()) let boolStream = Kefir.map((rand) => rand > 0.5) I want to emit true when boolStream emits true for 5 seconds (in a...

In RxJava, how to pass a variable along when chaining observables?

reactive-programming,rx-java,flatmap
I am chaining async operations using RxJava, and I'd like to pass some variable downstream: Observable .from(modifications) .flatmap( (data1) -> { return op1(data1); }) ... .flatmap( (data2) -> { // How to access data1 here ? return op2(data2); }) It seems like a common pattern but I couldn't find information...

How to get latest changed events of IObservable>?

c#,.net,system.reactive,reactive-programming,rx.net
My system has a lot of status objects - connections status, cpu load, logged users and so on. All of such events are merged into a single observable stream. I want to make a admin utility to show actual status of the system and to show all of that counters....

Cause helper to react to event

javascript,meteor,reactive-programming
I have a template with helpers and events like: Template.myTemplate.helpers({ edit: function () { console.log('helper'); return this.value; } }); Template.myTemplate.events({ 'click .edit_button': function () { console.log('click'); // Toggle the value this.value } }); Through the logs (simplified here) I can verify that the helper is called when the template is...

Restoring data 1 minute ago for time-shifted sequence

system.reactive,reactive-programming
This class accumulates values + knows at current moment the difference between current sum and sum 1 minute ago. Its client uses it in such way: adds new value for every incoming data chunk and gets the difference. Now, there's a problem with restoring its state. Suppose application gets recycled,...

F# Observable - Converting an event stream to a list

f#,functional-programming,reactive-programming,observable
I was writing an unit test that verified the events fired from a class. I followed the standard "IEvent<_>, Publish, Trigger inside an FSharp type" pattern. Can you recommend the "functional" way to achieve that? Here are the options I can think of: Convert the event stream into a list...

Looking back in the chain in RxJava

java,reactive-programming,rx-java
Random rand = new Random(); Observable<Integer> random1 = Observable.just(rand.nextInt()); Observable<Integer> random2 = random1.flatMap(r1->Observable.just(r1 * rand.nextInt())); random2.subscribe(System.out::println); The above code is just taking a couple of random numbers, multiplying them together, and printing the output. Here's my question: At the time that I print out the result, is there an elegant...

Lazy fetching of paginated objects using RxJava

android,pagination,reactive-programming,rx-java
I'm almost sold to RxJava, which is a perfect companion to Retrofit, but I'm struggling into a common pattern while migrating my code: to save bandwidth, I'd like to lazily fetch (paginated) objects from my webservice as needed, while my listview (or recyclerview) is scrolling using reactive programming. My previous...

Removing nested subscribeNext in reactive pipeline

ios,objective-c,reactive-programming,reactive-cocoa
I am trying to construct a reactive pipeline where a change in some input signals will trigger off an asynchronous web api request. But I do not need to perform anything in the subscribeNext block of the web api. This is how it looks: RACSignal *inputChanged = [[RACSignal merge:@[ RACObserve(self,...

How to get latest value from BehaviorSubject?

java,android,reactive-programming,rx-java,rx-android
How can I retrieve the latest value from BehaviorSubject on RxAndroid? Some background info: I'm using RxJava to implement MVVM pattern. My ViewModel encapsulates "bindable properties" that are BehaviorSubjects. I'm binding them to UI elements as observables, ensuring that the interface gets constantly updated (and thanks to using BehaviorSubject, it's...

How to prevent Scan from running multiple times?

.net,system.reactive,reactive-programming
For example var subject = new Subject<int>(); var test = subject.Scan(0, (x, y) => { Console.WriteLine("scan"); return x + 1; }); test.Subscribe(x => Console.WriteLine("subscribe1")); //test.Subscribe(x => Console.WriteLine("subscribe2")); Observable.Range(0, 1).Subscribe(subject); Console.WriteLine("done"); Console.Read(); The output is scan subscribe1 done But if you uncomment second Subscribe the output is scan subscribe1 scan subscribe2...

Transform Collection observable in Reactive X Java

java,reactive-programming,rx-java
I have a block of code that transforms a block of List[VideoDetails] into a VideoGrid using a couple map statements with ReactiveX: feedService.loadVideoDetailsFeed(things) .map(new Func1<List<VideoDetails>, List<Video>>() { @Override public List<Video> call(List<VideoDetails> details) { return Lists.transform(details, new Function<VideoDetails, Video>() { @Override public Video apply(VideoDetails input) { return input.getVideo(); } }); }...