ReactiveX / RxJavaFX

RxJava bindings for JavaFX
Apache License 2.0
520 stars 67 forks source link

More enhancements for CompositeObservable #39

Closed thomasnield closed 8 years ago

thomasnield commented 8 years ago

I won't make these changes right now. Just documenting them.

* Add vararg add() and remove() methods * Add clear() method to remove all Observables * Back with ObservableSet instead of ObservableList to prevent duplicates * Add getBackingList() to return unmodifiable ObservableList<Observable<T>> for currently tracked Observables.

thomasnield commented 8 years ago

The use of initialCapacity might be broken too as the caching happens to each independent subscription. Client might as well cache it themselves with that behavior. But the desired behavior is to have caching happen for all subscribers.

thomasnield commented 8 years ago

For RxKotlinFX, perhaps an Observable#addTo(CompositeObservable) extension function would be helpful as well to keep it fluent.

thomasnield commented 8 years ago

I think I got it. A compose() lambda should be passed as an optional argument to do any manipulations to the aggregated Observable.

CompositeObservable<Int> selectedId = 
    new CompositeObservable<>(obs -> obs.cache(1).publish().refCount());

This will take care of caching, publishing, and any other options you would like to do to the aggregated Observable returned from toObservable().

thomasnield commented 8 years ago

Released in RxJavaFX 0.2.0. I think this is a wrap.