Skip to content

Commit c21bcaf

Browse files
committed
2.1 Added `from(future, timeout)
1 parent 486ffe3 commit c21bcaf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Part 2 - Sequence Basics/1. Creating a sequence.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ Completed
276276

277277
The observable emits the result of the `FutureTask` when it is available and then terminates. If the task is canceled, the observable will emit a `java.util.concurrent.CancellationException` error.
278278

279+
If you're interested in the results of the `Future` for a limited amount of time, you can provide a timeout period like this
280+
```java
281+
Observable<Integer> values = Observable.from(f, 1000, TimeUnit.MILLISECONDS);
282+
```
283+
If the `Future` has not completed the specified amount of time, the observable will ignore it and fail with a `TimeoutException`.
284+
279285
You can also turn any collection into an observable using the overloads of `Observable.from` that take arrays and iterables. This will result in every item in the collection to be emitted and then the observable will terminate.
280286

281287
```java

0 commit comments

Comments
 (0)