new example fromCallable
This commit is contained in:
parent
9bbdcb6e8e
commit
cd00edc72e
1 changed files with 19 additions and 0 deletions
19
src/main/java/rx/create/FromCallable.java
Normal file
19
src/main/java/rx/create/FromCallable.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package rx.create;
|
||||
|
||||
import io.reactivex.Flowable;
|
||||
|
||||
/*
|
||||
* Flowable = Observable
|
||||
* fromCallable is another way of deferring. It creates an observable from the result of call.
|
||||
* Please note that the callable is not being called asynchronously. It's just deferred until subscription.
|
||||
*/
|
||||
public class FromCallable {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("current thread: " + Thread.currentThread());
|
||||
|
||||
Flowable.fromCallable(() -> {
|
||||
System.out.println(Thread.currentThread() + ": returning 'hello world'");
|
||||
return "hello world";
|
||||
}).subscribe();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue