All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.reactfx.ForgetfulEventStream Maven / Gradle / Ivy

There is a newer version: 2.0-M5
Show newest version
package org.reactfx;

class ForgetfulEventStream extends SuspendableEventStreamBase {
    private boolean hasValue = false;
    private T value = null;

    ForgetfulEventStream(EventStream source) {
        super(source);
    }

    @Override
    protected void handleEventWhenSuspended(T event) {
        value = event;
        hasValue = true;
    }

    @Override
    protected void onResume() {
        if(hasValue) {
            T toEmit = value;
            reset();
            emit(toEmit);
        }
    }

    @Override
    protected void reset() {
        hasValue = false;
        value = null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy