1. Creating Observable
--------------------------------------------------
Observable.<String>create(s ->{
s.onNext("I created succesfully");
s.onComplete();
});
--------------------------------------------------
2. Creating Observable and do some work
--------------------------------------------------
Observable.<String>create(s ->{
String calc1 = doSomething();
s.onNext(calc1);
String calc2 = doSomeOtherthing();
s.onNext(calc2);
s.onComplete();
});
3. Map
----------------------------------------
Observable.just(1,2,3,4)
.map(x -> x+" text") or .map(x -> x+1)
.subscribe(System.out::println);
----------------------------------------
22
No comments:
Post a Comment