E - the type of element in the setjava.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, javafx.beans.Observable, javafx.collections.ObservableSet<E>public class SubscribeableContentsObsSet<E>
extends java.util.AbstractSet<E>
implements javafx.collections.ObservableSet<E>
ObservableSet implementation that allows one to subscribe to updates within
the elements themselves. For example, if one stored Text in this set and one wanted
to be notified each time one of the text's textProperty() changed,
one could use addSubscriber(Function) with the function
text -> {
EventStream<String> textValues = EventStreams.nonNullValuesOf(text.textProperty());
return EventStreams.combine(textValues, otherTextValuesFromSomewhereElse)
.subscribe(tuple2 -> {
String quantity = tuple2.get1();
String unit = tuple2.get2();
someOtherObjectOnTheScreen.setText("Will send " + quantity + " " + unit + " to the department");
});
}
When the element is removed from the set, the function's returned Subscription is
unsubscribed to prevent any memory leaks.| Constructor | Description |
|---|---|
SubscribeableContentsObsSet() |
|
SubscribeableContentsObsSet(java.util.Comparator<? super E> comparator) |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
add(E e) |
|
org.reactfx.Subscription |
addChangeListener(javafx.collections.SetChangeListener<? super E> listener) |
Helper method for adding a change listener that can be removed by calling
unsubscribe on the returned Subscription. |
org.reactfx.Subscription |
addInvalidationListener(javafx.beans.InvalidationListener listener) |
Helper method for adding an invalidation listener that can be removed by calling
unsubscribe on the returned Subscription. |
void |
addListener(javafx.beans.InvalidationListener listener) |
|
void |
addListener(javafx.collections.SetChangeListener<? super E> listener) |
|
org.reactfx.Subscription |
addSubscriber(java.util.function.Function<? super E,org.reactfx.Subscription> subscriber) |
Subscribes to all current and future elements' internal changes in this set until either they are removed
or this subscriber is removed by calling
unsubscribe on the function's
returned Subscription. |
java.util.Iterator<E> |
iterator() |
|
boolean |
remove(java.lang.Object o) |
|
void |
removeListener(javafx.beans.InvalidationListener listener) |
|
void |
removeListener(javafx.collections.SetChangeListener<? super E> listener) |
|
int |
size() |
addAll, clear, contains, containsAll, isEmpty, retainAll, toArray, toArray, toStringpublic SubscribeableContentsObsSet()
public SubscribeableContentsObsSet(java.util.Comparator<? super E> comparator)
public java.util.Iterator<E> iterator()
public int size()
public boolean add(E e)
public boolean remove(java.lang.Object o)
public org.reactfx.Subscription addSubscriber(java.util.function.Function<? super E,org.reactfx.Subscription> subscriber)
unsubscribe on the function's
returned Subscription.public org.reactfx.Subscription addChangeListener(javafx.collections.SetChangeListener<? super E> listener)
unsubscribe on the returned Subscription.public org.reactfx.Subscription addInvalidationListener(javafx.beans.InvalidationListener listener)
unsubscribe on the returned Subscription.public void addListener(javafx.collections.SetChangeListener<? super E> listener)
addListener in interface javafx.collections.ObservableSet<E>public void removeListener(javafx.collections.SetChangeListener<? super E> listener)
removeListener in interface javafx.collections.ObservableSet<E>public void addListener(javafx.beans.InvalidationListener listener)
addListener in interface javafx.beans.Observablepublic void removeListener(javafx.beans.InvalidationListener listener)
removeListener in interface javafx.beans.Observable