org.reactfx.DistinctStream 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;
import java.util.Objects;
/**
* See {@link EventStream#distinct()}
*/
class DistinctStream extends EventStreamBase {
static final Object NONE = new Object();
private final EventStream input;
private Object previous = NONE;
public DistinctStream(EventStream input) {
this.input = input;
}
@Override
protected Subscription observeInputs() {
return input.subscribe(value -> {
Object prevToCompare = previous;
previous = value;
if (!Objects.equals(value, prevToCompare)) {
emit(value);
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy