Skip to content

Commit a3daa2f

Browse files
committed
Add CompositeBinding docs
1 parent ebec8ec commit a3daa2f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,19 @@ binding.dispose();
186186

187187
```
188188

189+
You also have the option to use a `CompositeBinding` to group multiple `Binding`s together, and `dispose()` them all at once. It is the JavaFX equivalent to `CompositeSubscription`.
190+
191+
```java
192+
Binding<Long> binding1 = ...
193+
bindings.add(binding1);
194+
195+
Binding<Long> binding2 = ...
196+
bindings.add(binding2);
197+
198+
//do stuff on UI, and dispose() both bindings
199+
bindings.dispose();
200+
```
201+
189202
### JavaFX Scheduler
190203

191204
When you update any JavaFX control, it must be done on the JavaFX Event Dispatch Thread. Fortunately, the `JavaFxScheduler` makes it trivial to take work off the JavaFX thread and put it back when the results are ready. Below we can use the `observeOn()` to pass text value emissions to a computation thread where the text will be flipped. Then we can pass `JavaFxScheduler.getInstance()` to another `observeOn()` afterwards to put it back on the JavaFX thread. From there it will update the `flippedTextLabel`.

0 commit comments

Comments
 (0)