Coder Social home page Coder Social logo

Comments (9)

rguillens avatar rguillens commented on May 14, 2024 1

I understand what you mean, a workaround could be subscribing with method references:

Subject subject = ...
Disposable disposable = myEventsObservable.subscribe(subject::onNext, subject::onError, subject::onComplete);

from rxjavafx.

rguillens avatar rguillens commented on May 14, 2024

I've tested different scenarios, and I can say Subject is a most straight forward solution than CompositeObservable. I'm just re-thinking about all common scenarios involving concurrency , although ideally CompositeObservable should be used to listen UI events from other layer, as events are always produced on JavaFx Application Thread, theorically there should be no problem.

from rxjavafx.

thomasnield avatar thomasnield commented on May 14, 2024

Yes those were kind of my thoughts. I have thought about making an FXSubject that would handle serialization and observing on the FX thread. I havent entirely dismissed that idea but in a great majority of cases, emissions going in and out should already be on the FX thread anyway. I can see occasional situations it might be useful though...

from rxjavafx.

thomasnield avatar thomasnield commented on May 14, 2024

I have found a potentially serious issue: subscribing a subject does not return a Disposable.

from rxjavafx.

rguillens avatar rguillens commented on May 14, 2024

Explain this issue a little more. The only subscribe implementation that doesn't return a Disposable in Observable is public final void subscribe(io.reactivex.Observer<? super T> observer) and all Subjects inherit this method.

from rxjavafx.

thomasnield avatar thomasnield commented on May 14, 2024

I'll post a better example tomorrow, but...

Subject subject = ...
myEventsObservable.subscribe(subject); // Does not return Disposable

from rxjavafx.

thomasnield avatar thomasnield commented on May 14, 2024

Yup, good thought. I looked at my implementation of CompositeObservable and that is exactly what I did.

https://github.com/ReactiveX/RxJavaFX/blob/2.x/src/main/java/io/reactivex/rxjavafx/sources/CompositeObservable.java

I'm a tad unsure what to do here... whether to tell users to do that subscribe() trick themselves, implement a new utility, or keep things as is.

Too bad Java doesn't have extension functions like Kotlin. Those would be pretty handy for this problem right now...

from rxjavafx.

thomasnield avatar thomasnield commented on May 14, 2024

I wonder if its possible creating a Subject implementation that does all this, and can have a dispose() method on it.

from rxjavafx.

thomasnield avatar thomasnield commented on May 14, 2024

I think I'm going to deprecate. I see @akarnokd gave a thumbs up to the subject route, so that's enough to push me out of my quandary.

from rxjavafx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.