org.reactfx.DistinctStream 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
The newest version!
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