diff --git a/src/main/java/com/yudong80/reactivejava/chapter04/conditional/AllFunctionExample.java b/src/main/java/com/yudong80/reactivejava/chapter04/conditional/AllFunctionExample.java index cf8a142..3794afe 100644 --- a/src/main/java/com/yudong80/reactivejava/chapter04/conditional/AllFunctionExample.java +++ b/src/main/java/com/yudong80/reactivejava/chapter04/conditional/AllFunctionExample.java @@ -22,7 +22,7 @@ public void marbleDiagram() { .map(Shape::getShape) .all(Shape.BALL::equals); //.all(val -> Shape.BALL.equals(Shape.getShape(val))); - source.subscribe(Log::i); + source.subscribe(val -> Log.i(val)); } public void wrongCase() { @@ -36,7 +36,7 @@ public void wrongCase() { .doOnSuccess(v -> Log.d("onSuccess : val = " + v)); //.all(val -> Shape.BALL.equals(Shape.getShape(val))); - source.subscribe(Log::i); + source.subscribe(val -> Log.i(val)); } public static void main(String[] args) { diff --git a/src/main/java/com/yudong80/reactivejava/chapter05/examples/OpenWeatherMapV2.java b/src/main/java/com/yudong80/reactivejava/chapter05/examples/OpenWeatherMapV2.java index 669166e..a3ae468 100644 --- a/src/main/java/com/yudong80/reactivejava/chapter05/examples/OpenWeatherMapV2.java +++ b/src/main/java/com/yudong80/reactivejava/chapter05/examples/OpenWeatherMapV2.java @@ -20,15 +20,18 @@ public class OpenWeatherMapV2 { public void run() { CommonUtils.exampleStart(); - Observable source = Observable.just(URL + API_KEY) + ConnectableObservable source = Observable.just(URL + API_KEY) .map(OkHttpHelper::getWithLog) .subscribeOn(Schedulers.io()) .share() - .observeOn(Schedulers.newThread()); - + .observeOn(Schedulers.newThread()) + .publish(); + source.map(this::parseTemperature).subscribe(Log::it); source.map(this::parseCityName).subscribe(Log::it); source.map(this::parseCountry).subscribe(Log::it); + + source.connect(); CommonUtils.sleep(1000); }