org.reactfx.AccumulatingStream 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 java.util.function.BiFunction;
import java.util.function.Function;
class AccumulatingStream extends LazilyBoundStream {
private final EventStream input;
private final Function super T, ? extends U> initialTransformation;
private final BiFunction super U, ? super T, ? extends U> reduction;
private boolean hasEvent = false;
private U event = null;
public AccumulatingStream(
EventStream input,
Function super T, ? extends U> initial,
BiFunction super U, ? super T, ? extends U> reduction) {
this.input = input;
this.initialTransformation = initial;
this.reduction = reduction;
}
@Override
protected final Subscription subscribeToInputs() {
return subscribeTo(input, i -> {
event = hasEvent
? reduction.apply(event, i)
: initialTransformation.apply(i);
hasEvent = true;
emit(event);
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy