Giter Club home page Giter Club logo

Comments (5)

thomasnield avatar thomasnield commented on August 15, 2024

Makes perfect sense. I'll implement this later in 1.0 as well as the 2.0 branch.

from rxjavafx.

thomasnield avatar thomasnield commented on August 15, 2024

Wouldn't it make more sense to emit an ObservableValue<T> rather than just a JavaFX Observable? The JavaFX Observable (not Rx one) does not have the getValue() method, but the ObservableValue<T> does. I imagine that would be more useful.

    public static <T> Observable<ObservableValue<T>> fromInvalidations(final ObservableValue<T> fxObservable) {
        return Observable.create(subscriber -> {
            final InvalidationListener listener = s -> subscriber.onNext(fxObservable);
            fxObservable.addListener(listener);
            subscriber.add(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> fxObservable.removeListener(listener)));
        });
    }

Would it also make sense to overload a Property<T> version as well? That way we can have access to a setValue() method for each emitted Property<T>?

    public static <T> Observable<Property<T>> fromInvalidations(final Property<T> fxProperty) {
        return Observable.create(subscriber -> {
            final InvalidationListener listener = s -> subscriber.onNext(fxProperty);
            fxProperty.addListener(listener);
            subscriber.add(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> fxProperty.removeListener(listener)));
        });
    }

from rxjavafx.

protogenes avatar protogenes commented on August 15, 2024

The main difference is, that ObservableList<>, ObservableSet<>, ObservableMap<> and Property<> all implement the Observable interface and this could be used without knowing the specific type. If you know it you should use valuesOf, changesOf and so on.

from rxjavafx.

thomasnield avatar thomasnield commented on August 15, 2024

@protogenes that makes sense. Okay I'll implement your way.

from rxjavafx.

thomasnield avatar thomasnield commented on August 15, 2024

@protogenes Implemented in 1.x. I'll do 2.x as soon as I merge the new Scheduler for that branch. Let me know if that's ready.

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.