Skip to content

Commit bee1b9f

Browse files
committed
change fromDialog() to return a Maybe instead of an Observable
1 parent cce2c29 commit bee1b9f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/main/java/io/reactivex/rxjavafx/observables/JavaFxObservable.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.reactivex.rxjavafx.observables;
1717

1818

19+
import io.reactivex.Maybe;
1920
import io.reactivex.Observable;
2021
import io.reactivex.rxjavafx.sources.*;
2122
import javafx.beans.value.ObservableValue;
@@ -367,9 +368,9 @@ public static Observable<Long> interval(final Duration duration) {
367368
}
368369

369370
/**
370-
* Returns an Observable that emits the T response of a Dialog. If no response was given then the Observable will be empty.
371+
* Returns a Maybe that emits the T response of a Dialog. If no response was given then the Maybe will be empty.
371372
*/
372-
public static <T> Observable<T> fromDialog(Dialog<T> dialog) {
373+
public static <T> Maybe<T> fromDialog(Dialog<T> dialog) {
373374
return DialogSource.fromDialogSource(dialog);
374375
}
375376
}

src/main/java/io/reactivex/rxjavafx/sources/DialogSource.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
*/
1616
package io.reactivex.rxjavafx.sources;
1717

18-
import io.reactivex.Observable;
18+
import io.reactivex.Maybe;
19+
import io.reactivex.Single;
1920
import io.reactivex.rxjavafx.schedulers.JavaFxScheduler;
2021
import javafx.scene.control.Dialog;
22+
2123
import java.util.Optional;
2224

2325
public final class DialogSource {
2426
private DialogSource() {}
2527

26-
public static <T> Observable<T> fromDialogSource(final Dialog<T> dialog) {
27-
return Observable.fromCallable(dialog::showAndWait)
28+
public static <T> Maybe<T> fromDialogSource(final Dialog<T> dialog) {
29+
return Single.fromCallable(dialog::showAndWait)
2830
.subscribeOn(JavaFxScheduler.platform())
2931
.filter(Optional::isPresent)
3032
.map(Optional::get);

0 commit comments

Comments
 (0)