
org.reactfx.SuspendableBoolean Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reactfx Show documentation
Show all versions of reactfx Show documentation
Reactive event streams for JavaFX
package org.reactfx;
import javafx.beans.value.ObservableBooleanValue;
import org.reactfx.value.ValBase;
abstract class SuspendableBoolean extends ValBase
implements ObservableBooleanValue, Suspendable {
private int suspenders = 0;
@Override
public final Guard suspend() {
if(++suspenders == 1) {
invalidate();
}
return ((Guard) this::release).closeableOnce();
}
private void release() {
assert suspenders > 0;
if(--suspenders == 0) {
invalidate();
}
}
public EventStream> yeses() {
return EventStreams.valuesOf(this).filterMap(val -> !val, val -> null);
}
public EventStream> noes() {
return EventStreams.valuesOf(this).filterMap(val -> val, val -> null);
}
protected final boolean isSuspended() {
return suspenders > 0;
}
@Override
protected final Subscription connect() {
return Subscription.EMPTY;
}
@Override
protected final Boolean computeValue() {
return get();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy