FAQ Database Discussion Community


String can not be casted to ObservableValue

java,casting,javafx-8,observable
I got a String in my model that I want to keep track of (the String represents a continent). If the continent changes, a ListView should be updated in the gui with the correct countries for that continent. String selectedContinent; ObservableValue continent = (ObservableValue) selectedContinent; continent.addListener( ...... Obviously I get...

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(() ->...

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...

Chaining promises with RxJS

javascript,observable,frp,rxjs
I'm new to RxJS and FRP in general. I had the idea of converting an existing promise chain in my ExpressJS application to be an observable for practice. I am aware that this probably isn't the best example but maybe someone can help shed some light. What I'm trying to...

Suspendable subscription in knockout

knockout.js,subscription,observable
I need to suspend a subscription in knockout. The reason is, after an observable is changed, it is necessary sometimes to change its value, and with subscription it ends up in recursion. I found the following SuspendableSubscription but I don't really know how to use it. My code is this.SearchParam.ProjectTypes.suspendableSubscribe(changeProjectType);...

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...

KendoUI - UI not refreshed after extracting repeating functions

javascript,kendo-ui,observable,kendo-mvvm,kendo-observable
I have a view model, which has several collection properties with some repeating logic. I need to be able to add a new empty object, to remove an object, and to ensure that every collection has at least one object, and if it is the only object, "Delete" button should...

How to create an Observable from an Observable>

java,rx-java,observable
If I have an Observable of a List of Letters public Observable<List<Letter>> getAToZList() { return Observable.create( new Observable.OnSubscribe<List<Letter>>() { @Override public void call(Subscriber<? super List<Letter>> subscriber) { List<Letter> aToZLetters = getLetters(); subscriber.onNext(aToZLetters); subscriber.onCompleted(); } } ); } How do I then create an Observable that observes a single Letter and...

RX - Group/Batch bursts of elements in an observable sequence

c#,system.reactive,observable
I have an observable sequence. When the first element is inserted, I would like to start a timer and batch subsequent inserted elements during the timespan of the timer. Then, the timer wouldn't start again until another element is inserted in the sequence. So something like this: --------|=====timespan====|---------------|=====timespan====|--------------> 1 2...

How to filter down dropdown results based on selection from another dropdown?

javascript,ember.js,ember-cli,observable
I would like to filter items by state and/or county. I am able to accomplish this, but what I would like to add is the functionality of only displaying de counties that are in relation with the chose state, if no state is chosen then show all available counties. I'm...

Avoid memory leak in subscription for baconjs

javascript,push,observable,bacon.js
I have a store in my application that uses the baconjs library. This store listens for changes of my authentication token. As the logged in user changes I then want to update listeners on other events to depend this new token. However, each time i log in with a new...

Knockout: Prevenet a property from adding into a computed's dependency list

knockout.js,observable
I have an infobox which is either open or closed depending on the value if isVisible property. self.infoboxState = ko.computed(function () { if (!ko.computedContext.isInitial()) { self.performAdditionalBehaviors(); } return ko.unwrap(self.isVisible)? 'infobox-open' : 'infobox-closed'; }, this); When we set the value of isVisible for the second time it would also execute performAdditionalBehaviors()...

Difference between Java 8 streams and RxJava observables

java-8,java-stream,rx-java,observable
Are Java 8 streams similar to RxJava observables? Java 8 stream definition: Classes in the new java.util.stream package provide a Stream API to support functional-style operations on streams of elements. ...

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...

Is it possible to inherit ko.computed to a prototype class?

javascript,knockout.js,observable
Let's say that I wish to have the behaviour a ko.computed has with: read write but I want to have an internal observable inside that ko.computed property, something like: this.a = ko.computed(function() { value: ko.observable(null), read: function() { return value; }, write: function(newValue) { if (newValue) { value(newValue); } }...

RxJava + retrofit, get a List and add extra info for each item

android,polling,retrofit,observable,rx-java
I'm playing around with RXJava, retrofit in Android. I'm trying to accomplish the following: I need to poll periodically a call that give me a Observable> (From here I could did it) Once I get this list I want to iterate in each Delivery and call another methods that will...

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,...

rxjava add items after observable was created

asynchronous,observable,rx-java,rx-android
I just started using rxjava and I got stuck. Maybe I'm not using rxjava in the right way, but I need to add items to an Observable after it was created. So I understand that You can just call Observable.just("Some", "Items") and the subscribers will receive them, but what if...

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...

Java: Can an Observer be notified of changes through a hierarchy of observers?

java,observer-pattern,runnable,observable
So I have a few classes that are just Observers, another that is both an Observer and Observable, and a third that is just Observable. I want to be able to take the class that is both and notify some of the Observers that the class that is only Observable...

How can i change a Field in a List of Objects with RXJava/Android

android,rx-java,observable
I have a List myPersonList an i wanna fill the Name and the City of every item. I have the id's already filled. I could create a foreach and call the FillPersonData but how can i do this with Observables? I know there is something with Map() and FlatMap() ......

Is using a Observable Singleton Class to handle network calls bad?

java,sockets,design-patterns,singleton,observable
I have to develop a client/server game that uses a lot of network request to complete its task. Both the client and the server receive multiple Command through socket. To handle these commands I created a NetworkHandler class that listens for new Input on a separate thread and that allow...

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...

Call service only if preceding observable succeeded

retrofit,observable,rx-java,rx-android
Background I am just diving into the concept of RX for java. Frankly, I don't get it. In my project I use retrofit library for calling services. Currently, I have implemented all the services using callback. If I want to orchestrate service calls I have to call callbacks in callbacks...

How do I create an Rx observable that gets an immediate value and then samples?

c#,.net,system.reactive,observable
I want to use Sample to reduce the frequency of items coming out of my observable, but I want to immediately see the first event go through without being held up for the sample duration. After that I want the Sample to only give me an item on the sample...

How to use .NET Rx FromEvent so that add event handler is called once and remove handler is called on demand

.net,system.reactive,observable
Is it possible to use .NET Rx Observable.FromEvent method or is there another method that allows to create an Observable from an event but calls add event handler only once when the first Subscribe method is called or when the FromEvent (or similar method) is called and don't call remove...

FilteredList gives java.lang.ArrayIndexOutOfBoundsException on update

java,javafx,observablecollection,observable
I created a simple application to test filtered lists and their behavior when the corresponding source list changes. I'd like to test update changes also, so I created ObservableList of ObservableLists. It is faster and simpler than creating additional class like Person that have observable fields. The code looks so:...

RxScala Observables with replay

scala,observable,replay,rx-scala
I'm trying to understand replay in RxScala. I create an observable like this: lazy val toyObservable : Observable[Int] = { val coldObservable : Observable[Int] = intPerSecond val hotObservable : ConnectableObservable[Int] = coldObservable.publish val cachedObservable = hotObservable //.replay(3) //<<<<<<<<< ODD THING cachedObservable.connect cachedObservable } where intPerSecond shoots out one integer per...

RXJS .filter and distinctUntilChanged on mouseover

observable,rxjs
In the RXJS autocomplete example you can filter keyup events but how can I filter mouseenter and mouseleave events?

JavaFX - Automatically update a choiceBox

javafx,observable
I have a Thread which permantly updates/creates a List: private ObservableList<String> query() { try { return FXCollections.observableArrayList(getWMIValue(query, fieldName)); } catch (Exception e) { return FXCollections.observableArrayList(""); } } @Override public void run() { while (true) { devices = query(); try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(WmiAccess.class.getName()).log(Level.SEVERE, null, ex); }...

How can I reuse a Subscriber between two Observables (RxJava)

java,rx-java,observable
In order to not repeat myself, I want to re-use a Subscriber variable between two observables. How do you do accomplish this? My current code below does not work, because after the subscriber is used once, it is unsubscribed and no longer works again. If I new a Subscriber instead...

How can you implement ZipLongest in Rx?

c#,system.reactive,observable
I'm trying to Zip two observable sequences of different lengths but I want the combined sequence to have the length of the largest sequence, padded with the last value of the shortest sequence. That is, if sequence 1 is [0,1,2] and sequence 2 is [0,1,2,3], I would like the result...

How to transform a nested list of double values into a Java class using RxJava?

android,retrofit,rx-java,observable,rx-android
In my Android client I receive this JSON data from a backend: [ [ 1427378400000, 553 ], [ 1427382000000, 553 ] ] Here is the routine which actually loads the data. I am using RxAndroid and Retrofit here. private void getProductLevels() { Observable<List<List<Double>>> responseObservable = mProductService.readProductLevels(); AppObservable.bindFragment(this, responseObservable) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread())...

Observable/Subscriber in AsyncTask

android,rx-java,observable
I'm trying to implement an Observable/Subscriber with RxJava on the onPostExecute() of an AsyncTask and I don't get how to make the connection. I create the Observable in the onPostExecute method. I want MyFragment to subscribe to this. How do I set this up? public class LoadAndStoreDataTask extends AsyncTask<String, Integer,...

Is it the best to implement ObservableBase in this situation or is there another way?

c#,.net,system.reactive,observable
First of all, I didn't find a good example of custom implementation of the ObservableBase or AnonymousObservable. I have no idea which one I need to implement in my case if any. The situation is this. I use a third-party library and there is a class let's call it Producer...

Cannot observe properties of nested elements in Safari 8.0 (iPad, iOS 8.1.3) in Polymer.dart

dart,dart-polymer,observable
I'm trying to observe a property change from nested Dart PolymerElements. It works in Firefox, Chrome, but not in Safari 8.0 on iPad (iOS 8.1.3): index.html file: <!DOCTYPE html> <html> <head> <title>Test</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta...

How to observe an array of NSObjects in swift?

arrays,swift,nsobject,observable,observers
I am new in swift language and my problem is about how to use observable/observer pattern in swift. I want to make my array to be observable in my SocketManager class so it can be observed by my UIViewController class. I have used the Observable class written by Andrew J...

How to use observables in F#

forms,user-interface,merge,f#,observable
I am trying to create a graphical application in F# using observables. The code I have so far is: open System.Windows.Forms let form = new Form(Text="Test", TopMost=true) let buttonNum0 = new Button(Text="1"); let buttonNum1 = new Button(Text="2", Top=20); let buttonNum2 = new Button(Text="3", Top=40); let buttonNum3 = new Button(Text="4", Top=60);...

How can I make one RxJS Observable sequence wait for another to complete before emitting?

javascript,observable,rxjs
Say I have an Observable, like so: var one = someObservable.take(1); one.subscribe(function(){ /* do something */ }); Then, I have a second observable: var two = someOtherObservable.take(1); Now, I want to subscribe to two, but I want to make sure that one has completed before the two subscriber is fired....

Why are these RxJS observables producing strange outputs?

javascript,observable,rxjs
I have two observables that are created from the same source. They are differentiated by a map that assigns a randomized value to a property of the element being emitted. Here is an example of the logic: var Rx = require('rx'); var _ = require('lodash'); // create a source that...