You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-37Lines changed: 39 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
# RxJavaFX: JavaFX bindings for RxJava
4
4
5
+
Read the free eBook [_Learning RxJava with JavaFX_](https://www.gitbook.com/book/thomasnield/rxjavafx-guide/details) to get started!
6
+
5
7
Learn more about RxJava on the <ahref="https://github.com/ReactiveX/RxJava/wiki">Wiki Home</a> and the <ahref="http://techblog.netflix.com/2013/02/rxjava-netflix-api.html">Netflix TechBlog post</a> where RxJava was introduced.
6
8
7
9
RxJavaFX is a simple API to convert JavaFX events into RxJava Observables and vice versa. It also has a scheduler to safely move emissions to the JavaFX Event Dispatch Thread.
@@ -61,19 +63,19 @@ $ ./gradlew build
61
63
62
64
## Features
63
65
64
-
RxJavaFX has a lightweight set of features:
66
+
RxJavaFX has a comprehensive set of features to interop RxJava with JavaFX:
65
67
- Factories to turn `Node`, `ObservableValue`, `ObservableList`, and other component events into an RxJava `Observable`
66
68
- Factories to turn an RxJava `Observable` into a JavaFX `Binding`.
67
69
- A scheduler for the JavaFX dispatch thread
68
70
69
71
###Node Events
70
-
You can get event emissions by calling `JavaFxObservable.fromNodeEvents()` and pass the JavaFX `Node` and the `EventType` you are interested in. This will return an RxJava `Observable`.
72
+
You can get event emissions by calling `JavaFxObservable.eventsOf()` and pass the JavaFX `Node` and the `EventType` you are interested in. This will return an RxJava `Observable`.
Note that many Nodes in JavaFX will have an initial value, which sometimes can be `null`, and you might consider using RxJava's `skip()` operator to ignore this initial value.
142
144
143
145
#####ObservableValue Changes
144
146
145
-
For every change to an `ObservableValue`, you can emit the old value and new value as a pair. The two values will be wrapped up in a `Change` class and you can access them via `getOldVal()` and `getNewVal()`. Just call the `JavaFxObservable.fromObservableValueChanges()` factory.
147
+
For every change to an `ObservableValue`, you can emit the old value and new value as a pair. The two values will be wrapped up in a `Change` class and you can access them via `getOldVal()` and `getNewVal()`. Just call the `JavaFxObservable.valuesOfChanges()` factory.
|fromObservableList()|ObservableList<T>|Observable<ObservableList<T>>|Emits the entire `ObservableList` every time it changes|
167
-
|fromObservableListAdds()|ObservableList<T>|Observable<T>|Emits additions to an `ObservableList`|
168
-
|fromfromObservableListRemovals()|ObservableList<T>|Observable<T>|Emits removals from an `ObservableList`|
169
-
|fromObservableListUpdates|ObservableList<T>|Observable<ListChange<T>>|Emits every item that was the result of a change to an `ObservableList`, with an `ADDED`, `REMOVED`, or `UPDATED` flag|
170
-
|fromObservableListDistinctChanges()|ObservableList<T>| Observable<ListChange<R>>|Emits only *distinct* addtions and removals to an `ObservableList`|
171
-
|fromObservableListDistinctChanges()|ObservableList<T>, Func1<T,R>| Observable<ListChange<R>>|Emits only *distinct* additions and removals to an `ObservableList` and emits the mapping|
172
-
|fromObservableListDistinctChanges()|ObservableList<T>, Func1<T,R>| Observable<ListChange<R>>|Emits only *distinct* additions and removals to an `ObservableList` based on a mapping|
173
-
|fromObservableMap()|ObservableMap<K,T>|Observable<ObservableMap<K,T>>|Emits the entire `ObservableMap` every time it changes|
174
-
|fromObservableMapAdds()|ObservableMap<K,T>|Observable<Map.Entry<K,T>>|Emits every `Map.Entry<K,T>` added to an `ObservableMap`|
175
-
|fromObservableMapRemovals()|ObservableMap<K,T>|Observable<Map.Entry<K,T>>|Emits every `Map.Entry<K,T>` removed from an `ObservableMap`|
176
-
|fromObservableMapChanges()|ObservableMap<K,T>|Observable<MapChange<K,T>>|Emits every key/value pair with an `ADDED` or `REMOVED` flag.|
177
-
|fromObservableSet()|ObservableSet<T>|Observable<ObservableSet<T>>|Emits the entire `ObservableSet` every time it changes|
178
-
|fromObservableSetAdds()|ObservableSet<T>|Observable<T>|Emits every addition to an `ObservableSet`|
179
-
|fromObservableSetRemovals()|ObservableSet<T>|Observable<T>|Emits every removal to an `ObservableSet`|
180
-
|fromObservableSetChanges()|ObservableSet<T>|Observable<SetChange<T>|Emits every item `ADDED` or `REMOVED` item from an `ObservableSet` with the corresponding flag|
168
+
|emitOnChanged()()|ObservableList<T>|Observable<ObservableList<T>>|Emits the entire `ObservableList` every time it changes|
169
+
|additionsOf()|ObservableList<T>|Observable<T>|Emits additions to an `ObservableList`|
170
+
|removalsOf()|ObservableList<T>|Observable<T>|Emits removals from an `ObservableList`|
171
+
|updatesOf()|ObservableList<T>|Observable<ListChange<T>>|Emits every item that was the result of a change to an `ObservableList`, with an `ADDED`, `REMOVED`, or `UPDATED` flag|
172
+
|distinctChangesOf()|ObservableList<T>| Observable<ListChange<R>>|Emits only *distinct* addtions and removals to an `ObservableList`|
173
+
|distinctMappingsOf()|ObservableList<T>, Func1<T,R>| Observable<ListChange<R>>|Emits only *distinct* additions and removals to an `ObservableList` and emits the mapping|
174
+
|distinctChangesOf()|ObservableList<T>, Func1<T,R>| Observable<ListChange<R>>|Emits only *distinct* additions and removals to an `ObservableList` based on a mapping|
175
+
|emitOnChanged()|ObservableMap<K,T>|Observable<ObservableMap<K,T>>|Emits the entire `ObservableMap` every time it changes|
176
+
|additionsOf()|ObservableMap<K,T>|Observable<Map.Entry<K,T>>|Emits every `Map.Entry<K,T>` added to an `ObservableMap`|
177
+
|removalsOf()|ObservableMap<K,T>|Observable<Map.Entry<K,T>>|Emits every `Map.Entry<K,T>` removed from an `ObservableMap`|
178
+
|changesOf()|ObservableMap<K,T>|Observable<MapChange<K,T>>|Emits every key/value pair with an `ADDED` or `REMOVED` flag.|
179
+
|emitOnChanged()|ObservableSet<T>|Observable<ObservableSet<T>>|Emits the entire `ObservableSet` every time it changes|
180
+
|additionsOf()|ObservableSet<T>|Observable<T>|Emits every addition to an `ObservableSet`|
181
+
|removalsOf()|ObservableSet<T>|Observable<T>|Emits every removal to an `ObservableSet`|
182
+
|changesOf()|ObservableSet<T>|Observable<SetChange<T>|Emits every item `ADDED` or `REMOVED` item from an `ObservableSet` with the corresponding flag|
181
183
182
184
183
185
###Binding
@@ -188,7 +190,7 @@ Button incrementBttn = new Button("Increment");
Every time you `add()`or `remove()` an `Observable` to a `CompositeObservable`, it will affect all existing Subscribers. For UI development, this is good because there is no sensitivity to the order of adding Observables and subscribing.
314
+
The `add()`method on a `CompositeObservable` returns a subscription which you can `unsubscribe()`, and this will affect all existing downstream Subscribers. For UI development, this is good because there is no sensitivity to the order of adding Observables and subscribing.
313
315
314
316
Of course, you can pass around any type `T` in a `CompositeObservable<T>` and not just `ActionEvent`. It can be = helpful to pass around entire data structures, such as `CompositeObservable<Set<MyType>>`, to relay requests and inputs between controls.
315
317
@@ -328,7 +330,7 @@ TextField textInput = new TextField();
0 commit comments