
org.reactfx.EmitOnEachStream 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 org.reactfx.util.Either;
import org.reactfx.util.Tuple2;
import org.reactfx.util.Tuple3;
class EmitOnEachStream extends LazilyBoundStream {
private final EventStream source;
private final EventStream> impulse;
private boolean hasValue = false;
private T value = null;
public EmitOnEachStream(EventStream source, EventStream> impulse) {
this.source = source;
this.impulse = impulse;
}
@Override
protected Subscription subscribeToInputs() {
Subscription s1 = subscribeTo(source, v -> {
hasValue = true;
value = v;
});
Subscription s2 = subscribeTo(impulse, i -> {
if(hasValue) {
emit(value);
}
});
return s1.and(s2);
}
}
class EmitOnEachBiStream
extends EmitOnEachStream>
implements PoorMansBiStream {
public EmitOnEachBiStream(
EventStream> source,
EventStream> impulse) {
super(source, impulse);
}
}
class EmitOnEachTriStream
extends EmitOnEachStream>
implements PoorMansTriStream {
public EmitOnEachTriStream(
EventStream> source,
EventStream> impulse) {
super(source, impulse);
}
}
@Deprecated
class EmitOnEachEitherStream
extends EmitOnEachStream>
implements EitherEventStream {
public EmitOnEachEitherStream(
EventStream> source,
EventStream> impulse) {
super(source, impulse);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy