@@ -10,7 +10,7 @@ RxJavaFX is a lightweight library to convert JavaFX events into [RxJava](https:/
1010
1111## Master Build Status
1212
13- <a href =' https://travis-ci.org/ReactiveX/RxJavaFX/builds ' ><img src =' https://travis-ci.org/ReactiveX/RxJavaFX.svg?branch=0 .x ' ></a >
13+ <a href =' https://travis-ci.org/ReactiveX/RxJavaFX/builds ' ><img src =' https://travis-ci.org/ReactiveX/RxJavaFX.svg?branch=2.11 .x ' ></a >
1414
1515## Documentation
1616
@@ -278,121 +278,6 @@ If you are heavily dependent on RxJava, asynchronous processing, or do not want
278278## Notes for Kotlin
279279If you are building your JavaFX application with [ Kotlin] ( https://kotlinlang.org/ ) , check out [ RxKotlinFX] ( https://github.com/thomasnield/RxKotlinFX ) to leverage this library through Kotlin extension functions.
280280
281- ## Comprehensive Example
282- ``` java
283- package io.reactivex.rxjavafx ;
284-
285- import io.reactivex.Observable ;
286- import io.reactivex.disposables.Disposable ;
287- import io.reactivex.rxjavafx.observables.JavaFxObservable ;
288- import io.reactivex.rxjavafx.observers.JavaFxObserver ;
289- import io.reactivex.rxjavafx.schedulers.JavaFxScheduler ;
290- import io.reactivex.schedulers.Schedulers ;
291- import javafx.application.Application ;
292- import javafx.beans.binding.Binding ;
293- import javafx.event.ActionEvent ;
294- import javafx.scene.Scene ;
295- import javafx.scene.control.* ;
296- import javafx.scene.layout.GridPane ;
297- import javafx.stage.Stage ;
298-
299- public class RxJavaFXTest extends Application {
300-
301- private final Button incrementBttn;
302- private final Label incrementLabel;
303- private final Binding<String > binding1;
304-
305- private final TextField textInput;
306- private final Label flippedTextLabel;
307- private final Binding<String > binding2;
308-
309- private final Spinner<Integer > spinner;
310- private final Label spinnerChangesLabel;
311- private final Disposable disposable;
312-
313- public RxJavaFXTest () {
314-
315- // initialize increment
316- // demoTurns button events into Binding
317- incrementBttn = new Button (" Increment" );
318- incrementLabel = new Label (" " );
319-
320- Observable<ActionEvent > bttnEvents =
321- JavaFxObservable . actionEventsOf(incrementBttn);
322-
323- binding1 = bttnEvents. map(e - > 1 ). scan(0 ,(x, y) - > x + y)
324- .map(Object :: toString)
325- .to(JavaFxObserver :: toBinding);
326-
327- incrementLabel. textProperty(). bind(binding1);
328-
329- // initialize text flipper
330- // Schedules on computation Scheduler for text flip calculation
331- // Then resumes on JavaFxScheduler thread to update Binding
332- textInput = new TextField ();
333- flippedTextLabel = new Label ();
334-
335- Observable<String > textInputs =
336- JavaFxObservable . valuesOf(textInput. textProperty());
337-
338- binding2 = textInputs. observeOn(Schedulers . computation())
339- .map(s - > new StringBuilder (s). reverse(). toString())
340- .observeOn(JavaFxScheduler . platform())
341- .to(JavaFxObserver :: toBinding);
342-
343- flippedTextLabel. textProperty(). bind(binding2);
344-
345- // initialize Spinner value changes
346- // Emits Change items containing old and new value
347- // Uses RxJava Subscription instead of Binding just to show that option
348- SpinnerValueFactory<Integer > svf = new SpinnerValueFactory .IntegerSpinnerValueFactory (0 , 100 );
349- spinner = new Spinner<> ();
350- spinner. setValueFactory(svf);
351- spinner. setEditable(true );
352-
353- spinnerChangesLabel = new Label ();
354- disposable = JavaFxObservable . changesOf(spinner. valueProperty())
355- .map(change - > " OLD: " + change. getOldVal() + " NEW: " + change. getNewVal())
356- .subscribe(spinnerChangesLabel:: setText);
357-
358- }
359-
360- @Override
361- public void start (Stage primaryStage ) throws Exception {
362-
363- GridPane gridPane = new GridPane ();
364-
365- gridPane. setHgap(10 );
366- gridPane. setVgap(10 );
367-
368- gridPane. add(incrementBttn,0 ,0 );
369- gridPane. add(incrementLabel,1 ,0 );
370-
371- gridPane. add(textInput,0 ,1 );
372- gridPane. add(flippedTextLabel, 1 ,1 );
373-
374- gridPane. add(spinner,0 ,2 );
375- gridPane. add(spinnerChangesLabel,1 ,2 );
376-
377- Scene scene = new Scene (gridPane);
378-
379-
380- primaryStage. setWidth(275 );
381- primaryStage. setScene(scene);
382- primaryStage. show();
383- }
384-
385- @Override
386- public void stop () throws Exception {
387- super . stop();
388-
389- binding1. dispose();
390- binding2. dispose();
391- disposable. dispose();
392- }
393- }
394- ```
395-
396281## Bugs and Feedback
397282
398283For bugs, questions and discussions please use the [ Github Issues] ( https://github.com/ReactiveX/RxJavaFX/issues ) .
0 commit comments