org.reactfx.EmitAllOnEachStream 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;
class EmitBothOnEachStream extends LazilyBoundBiStream {
private final EventStream source;
private final EventStream impulse;
private boolean hasValue = false;
private A a = null;
public EmitBothOnEachStream(EventStream source, EventStream impulse) {
this.source = source;
this.impulse = impulse;
}
@Override
protected Subscription subscribeToInputs() {
Subscription s1 = source.subscribe(a -> {
hasValue = true;
this.a = a;
});
Subscription s2 = impulse.subscribe(i -> {
if(hasValue) {
emit(a, i);
}
});
return s1.and(s2);
}
}
class EmitAll3OnEachStream extends LazilyBoundTriStream {
private final BiEventStream source;
private final EventStream impulse;
private boolean hasValue = false;
private A a = null;
private B b = null;
public EmitAll3OnEachStream(
BiEventStream source,
EventStream impulse) {
this.source = source;
this.impulse = impulse;
}
@Override
protected Subscription subscribeToInputs() {
Subscription s1 = source.subscribe((a, b) -> {
hasValue = true;
this.a = a;
this.b = b;
});
Subscription s2 = impulse.subscribe(i -> {
if(hasValue) {
emit(a, b, i);
}
});
return s1.and(s2);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy