From a95e8e2537cf2d49c4b2b062a2b24affe5fd262b Mon Sep 17 00:00:00 2001 From: Nick Pierre Date: Wed, 25 Oct 2017 16:10:47 -0400 Subject: [PATCH 1/7] Update to use javaDocs in favor of block comments --- src/test/java/lessonD_AdvancedStreams.java | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/test/java/lessonD_AdvancedStreams.java b/src/test/java/lessonD_AdvancedStreams.java index e73a64a..66e0a9d 100644 --- a/src/test/java/lessonD_AdvancedStreams.java +++ b/src/test/java/lessonD_AdvancedStreams.java @@ -14,14 +14,14 @@ public class lessonD_AdvancedStreams { private String mEvenNums = ""; private String mOddNums = ""; - /* - So far everything has been pretty linear. Our pipelines all took the form: - "do this, then do this, then do this, then end". In reality we can combine pipelines. We can take two streams - and turn them into a single stream. - - Now its worth nothing this is different from what we did when we nested Observables. In that case we always had one stream. - Lets take a stream of integers and a stream of strings and join them. - */ + /** + * So far everything has been pretty linear. Our pipelines all took the form: + * "do this, then do this, then do this, then end". In reality we can combine pipelines. We can take two streams + * and turn them into a single stream. + * + * Now its worth nothing this is different from what we did when we nested Observables. In that case we always had one stream. + * Lets take a stream of integers and a stream of strings and join them. + */ @Test public void _1_merging() { Observable you = Observable.just(1, 2, 3); @@ -32,15 +32,15 @@ public void _1_merging() { assertThat(mReceived).isEqualTo(_____); } - /* - We can also split up a single stream into two streams. We are going to to use the groupBy() action. - This action can be a little tricky because it emits an observable of observables. So we need to subscribe to the - "parent" observable and each emitted observable. - - We encourage you to read more from the wiki: http://reactivex.io/documentation/operators/groupby.html - - Lets split up a single stream of integers into two streams: even and odd numbers. - */ + /** + * We can also split up a single stream into two streams. We are going to to use the groupBy() action. + * This action can be a little tricky because it emits an observable of observables. So we need to subscribe to the + * "parent" observable and each emitted observable. + * + * We encourage you to read more from the wiki: http://reactivex.io/documentation/operators/groupby.html + * + * Lets split up a single stream of integers into two streams: even and odd numbers. + */ @Test public void _2_splittingUp() { Observable.range(1, 9) @@ -62,12 +62,12 @@ public void _2_splittingUp() { } - /* - Lets take what we know now and do some cool stuff. We've setup an observable and a function for you. Lets combine - them together to average some numbers. - - Also see that we need to subscribe first to the "parent" observable but that the pipeline still cold until we - subscribe to each subset observable. Don't forget to do that. + /** + * Lets take what we know now and do some cool stuff. We've setup an observable and a function for you. Lets combine + * them together to average some numbers. + * + * Also see that we need to subscribe first to the "parent" observable but that the pipeline still cold until we + * subscribe to each subset observable. Don't forget to do that. */ @Test public void _3_challenge_needToSubscribeImmediatelyWhenSplitting() { From 999647851b730941f032f6aebc1f5c8e4f4ea27f Mon Sep 17 00:00:00 2001 From: Nick Pierre Date: Wed, 25 Oct 2017 16:19:13 -0400 Subject: [PATCH 2/7] Further explanation on our usage of map() --- src/test/java/lessonB_MapAndFlatMapAndBasicOperators.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/java/lessonB_MapAndFlatMapAndBasicOperators.java b/src/test/java/lessonB_MapAndFlatMapAndBasicOperators.java index 0feb5be..a6866e6 100644 --- a/src/test/java/lessonB_MapAndFlatMapAndBasicOperators.java +++ b/src/test/java/lessonB_MapAndFlatMapAndBasicOperators.java @@ -90,9 +90,13 @@ public Observable call(List foods) { /** Was the result above what you expected? A bit strange huh? You'd think that you'd get * a value matching the number of items of foods in each list at first glance. * The reason we get a different result is because of the difference between map(), and flatmap(), which we will see next. + * * map() will always keep the SAME NUMBER OF events/ data as the previous segment in the pipeline. It can never change the number * of items on the previous piece of the pipeline. - + * + * In other words, our call to map() applies a function to each item in the foodcartItemsObservable. + * Within this function, we return Observable(s), of type carnivalFood, for each item in our foodcartItemsObservable. + * * Next, we would like to begin filtering the list to match what we can afford to eat. * The problem now is that rather than Observable items, we are emitting Observable>s instead. * We can't filter these, because Observable has no price (its content does, but we cant access that). From 505a506e3feee373656c1aea622b8862da52be06 Mon Sep 17 00:00:00 2001 From: Nick Pierre Date: Wed, 25 Oct 2017 16:20:53 -0400 Subject: [PATCH 3/7] Added links within javaDocs for referenced class definitions --- src/test/java/lessonA_CreatingObservableStreams.java | 2 +- src/test/java/lessonC_BooleanLogicAndErrorHandling.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/lessonA_CreatingObservableStreams.java b/src/test/java/lessonA_CreatingObservableStreams.java index 09c60de..a44fa76 100644 --- a/src/test/java/lessonA_CreatingObservableStreams.java +++ b/src/test/java/lessonA_CreatingObservableStreams.java @@ -136,7 +136,7 @@ public void _4_fromCreatesAnObservableThatEmitsEachElementFromAnIterable() { * So if we are going to build an observable and not subscribe to it until later on, how can we include the all * of the functionality as before? Do we have to put all the work inside subscribe() ? No we don't! *

- * If we peek at the Observer interface we see it has three methods: + * If we peek at the {@link rx.Observer} interface we see it has three methods: *

* public interface Observer { * void onCompleted(); diff --git a/src/test/java/lessonC_BooleanLogicAndErrorHandling.java b/src/test/java/lessonC_BooleanLogicAndErrorHandling.java index 85a8582..d824a67 100644 --- a/src/test/java/lessonC_BooleanLogicAndErrorHandling.java +++ b/src/test/java/lessonC_BooleanLogicAndErrorHandling.java @@ -73,8 +73,10 @@ public void _1_takeWhileEvaluatesAnExpressionAndEmitsEventsUntilItReturnsFalse() * * Riddle: Lets define our elevator rule: the total weight of all passengers aboard an elevator may not be larger than 500 pounds. * How!?! - * Hint: Check out the Public methods available on LessonResources.Elevator and passenger! - */ + * + * Hint: Check out the Public methods available on + * {@link LessonResources.Elevator} and {@link LessonResources.ElevatorPassenger}! + * */ Func1 elevatorRule = passenger -> ____ + ____ < ____; /** From 188d1af6b39eb6486d0dc99cc467d27e1e5dd5d9 Mon Sep 17 00:00:00 2001 From: Nick Pierre Date: Wed, 25 Oct 2017 16:35:14 -0400 Subject: [PATCH 4/7] Added upload method call, as this takes away from learning rxJava --- src/test/java/lessonC_BooleanLogicAndErrorHandling.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/lessonC_BooleanLogicAndErrorHandling.java b/src/test/java/lessonC_BooleanLogicAndErrorHandling.java index d824a67..c93bee3 100644 --- a/src/test/java/lessonC_BooleanLogicAndErrorHandling.java +++ b/src/test/java/lessonC_BooleanLogicAndErrorHandling.java @@ -106,6 +106,8 @@ public void _1_takeWhileEvaluatesAnExpressionAndEmitsEventsUntilItReturnsFalse() */ mSubscriber = new TestSubscriber<>(); // + // Lets start by emptying our elevator + // elevator.unload(); // ??? // // assertThat(mSubscriber.getOnNextEvents()).hasSize(3); From ec55552c0a6ae786976bc65ad5ab88f3343c1026 Mon Sep 17 00:00:00 2001 From: Nick Pierre Date: Wed, 25 Oct 2017 16:38:02 -0400 Subject: [PATCH 5/7] Added missing solution as comment --- src/test/java/solutions/lessonB_Solutions.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/solutions/lessonB_Solutions.java b/src/test/java/solutions/lessonB_Solutions.java index efae5f9..830e349 100644 --- a/src/test/java/solutions/lessonB_Solutions.java +++ b/src/test/java/solutions/lessonB_Solutions.java @@ -190,6 +190,7 @@ public void composableFunctions() { .subscribe(); assertThat(mStringA).isEqualTo("123456"); assertThat(mStringB).isEqualTo("246"); + //assertThat(mStringC).isEqualTo("112233445566"); // Uncommenting this will produce errors } /** From 596889e05988c303e2907628412fed318de39204 Mon Sep 17 00:00:00 2001 From: Nick Pierre Date: Wed, 25 Oct 2017 17:02:14 -0400 Subject: [PATCH 6/7] Corrected a typo --- src/test/java/lessonD_AdvancedStreams.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/lessonD_AdvancedStreams.java b/src/test/java/lessonD_AdvancedStreams.java index 66e0a9d..3161032 100644 --- a/src/test/java/lessonD_AdvancedStreams.java +++ b/src/test/java/lessonD_AdvancedStreams.java @@ -19,7 +19,7 @@ public class lessonD_AdvancedStreams { * "do this, then do this, then do this, then end". In reality we can combine pipelines. We can take two streams * and turn them into a single stream. * - * Now its worth nothing this is different from what we did when we nested Observables. In that case we always had one stream. + * Now its worth noting this is different from what we did when we nested Observables. In that case we always had one stream. * Lets take a stream of integers and a stream of strings and join them. */ @Test @@ -86,4 +86,4 @@ public void _3_challenge_needToSubscribeImmediatelyWhenSplitting() { assertThat(averages[0]).isEqualTo(22.0); assertThat(averages[1]).isEqualTo(100.0); } -} \ No newline at end of file +} From c926fd1c30332db6a795de4f2bf3f8362d5b288c Mon Sep 17 00:00:00 2001 From: Nick Pierre Date: Wed, 25 Oct 2017 17:11:11 -0400 Subject: [PATCH 7/7] Corrected typo --- src/test/java/lessonD_AdvancedStreams.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/lessonD_AdvancedStreams.java b/src/test/java/lessonD_AdvancedStreams.java index 3161032..afc9160 100644 --- a/src/test/java/lessonD_AdvancedStreams.java +++ b/src/test/java/lessonD_AdvancedStreams.java @@ -33,7 +33,7 @@ public void _1_merging() { } /** - * We can also split up a single stream into two streams. We are going to to use the groupBy() action. + * We can also split up a single stream into two streams. We are going to use the groupBy() action. * This action can be a little tricky because it emits an observable of observables. So we need to subscribe to the * "parent" observable and each emitted observable. *