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

org.reactfx.TaskStream Maven / Gradle / Ivy

There is a newer version: 1.11
Show newest version
package org.reactfx;

import javafx.concurrent.Task;

import org.reactfx.util.Try;

public interface TaskStream extends EventStream> {

    /**
     * Returns a new stream that emits the results of tasks emitted from this
     * stream when they become available.
     *
     * 

Note that results from the returned stream may arrive in different * order than the tasks emitted from this stream, due to asynchrony. * *

If a task emitted by this stream fails with exception {@code e}, * {@code Try.failure(e)} is emitted from the returned stream. */ default AwaitingEventStream> await() { return Await.awaitTask(this); } /** * Similar to {@link #await()}, with one difference: for tasks t1 and * t2 emitted from this stream in this order, if t2 arrives * before t1 is completed, then t1 is cancelled and its result * is discarded (i.e. not emitted from the returned stream). * @see #await() */ default AwaitingEventStream> awaitLatest() { return AwaitLatest.awaitTask(this); } /** * Similar to {@link #awaitLatest()}, with one addition: * When an event is emitted from {@code canceller}, if the task most * recently emitted from this stream has not yet completed, it is cancelled * and its result discarded (i.e. not emitted from the returned stream). * @param canceller An event from this stream causes the currently expected * result (if any) to be discarded. It can be used to signal that a new * task will arrive from this stream shortly, which makes the currently * expected result outdated. * @see #awaitLatest() */ default AwaitingEventStream> awaitLatest(EventStream canceller) { return AwaitLatest.awaitTask(this, canceller); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy