Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactive Dialogs and Alerts #37

Closed
thomasnield opened this issue Jul 13, 2016 · 3 comments
Closed

Reactive Dialogs and Alerts #37

thomasnield opened this issue Jul 13, 2016 · 3 comments

Comments

@thomasnield
Copy link
Collaborator

thomasnield commented Jul 13, 2016

I discovered a factory to implement reactive dialogs and alerts is quite simple.

Implementation

public static <T> Observable<T> fromDialogSource(final Dialog<T> dialog) {
    return Observable.fromCallable(dialog::showAndWait)
            .subscribeOn(JavaFxScheduler.getInstance())
            .filter(Optional::isPresent)
            .map(Optional::get);
}

Usage

JavaFxObservable.fromDialog(alert)
    .filter(response -> response.equals(ButtonType.OK))
    .subscribe(System.out::println,Throwable::printStackTrace);

I think I'm going to do a release with this and the fix for #36. Did I oversimplify this factory? Is there anything else that needs to be added?

@thomasnield
Copy link
Collaborator Author

Dang it, Travis build is failing due to its usage of Java version "1.8.0_31". Dialogs are only supported in 1.8.0_40 upwards. I can't find any current information beyond fall of 2015, but it seems Travis doesn't support beyond 1.8.0_31. I may have to turn off Travis unless anybody has ideas.

@thomasnield
Copy link
Collaborator Author

travis-ci/travis-ci#3259

@thomasnield
Copy link
Collaborator Author

Never mind fixed it. This modification to YML did the trick.

# install the newest java.
addons:
  apt:
    packages:
      - oracle-java8-installer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant