org.reactfx.RepeatOnStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of richtextfx Show documentation
Show all versions of richtextfx Show documentation
FX-Text-Area for formatted text and other special effects.
package org.reactfx;
/**
* See {@link EventStream#repeatOn(EventStream)}
*/
class RepeatOnStream extends EventStreamBase {
private final EventStream source;
private final EventStream> impulse;
private boolean hasValue = false;
private T value = null;
public RepeatOnStream(EventStream source, EventStream> impulse) {
this.source = source;
this.impulse = impulse;
}
@Override
protected Subscription observeInputs() {
Subscription s1 = source.subscribe(v -> {
hasValue = true;
value = v;
emit(v);
});
Subscription s2 = impulse.subscribe(i -> {
if(hasValue) {
emit(value);
}
});
return s1.and(s2);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy