You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Part 3 - Taming the sequence/4. Combining sequences.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Combining sequences
2
2
3
-
So far, we've seen most of the methods that allow us to create a sequence and transform it into what we want. However, most applications will have more than one sources of input. We need a way a of combining sequences. We've already seen a few sequences that use more than one observable. In this chapter, we will see the most important operators that use multiple sequences to produce one.
3
+
So far, we've seen most of the methods that allow us to create a sequence and transform it into what we want. However, most applications will have more than one source of input. We need a way a of combining sequences. We've already seen a few sequences that use more than one observable. In this chapter, we will see the most important operators that use multiple sequences to produce one.
4
4
5
5
## Concatenation
6
6
@@ -27,7 +27,7 @@ public static final <T> Observable<T> concat(Observable<? extends T> t1,
Concatenating two (or more) given observables is very straight forward.
30
+
Concatenating two (or more) given observables is straightforward.
31
31
32
32
```java
33
33
Observable<Integer> seq1 =Observable.range(0, 3);
@@ -46,7 +46,7 @@ Observable.concat(seq1, seq2)
46
46
12
47
47
```
48
48
49
-
If the number of sequences to be combined is dynamic, you can provide an observable that emits the sequences to be concatenated. In this example, we will use our familiar `groupBy` to create a sequence that emits words that start with the same letter together.
49
+
If the number of sequences to be combined is dynamic, you can provide an observable that emits the sequences to be concatenated. In this example, we will use our familiar `groupBy` to create a sequence that emits words starting with the same letter together.
50
50
51
51
```java
52
52
Observable<String> words =Observable.just(
@@ -106,7 +106,7 @@ public final Observable<T> repeat()
106
106
publicfinalObservable<T> repeat(long count)
107
107
```
108
108
109
-
It application is very simple
109
+
Its application is very simple
110
110
111
111
```java
112
112
Observable<Integer> words =Observable.range(0,2);
@@ -320,7 +320,7 @@ Second
320
320
First
321
321
```
322
322
323
-
The difference between `concat` and `merge` is that `merge` does not wait for the current observable to terminate before moving to the next. `merge` subscribes to every observable available to it and emits items as they come. It that way, `merge` is similar to the flattening part of `flatMap`.
323
+
The difference between `concat` and `merge` is that `merge` does not wait for the current observable to terminate before moving to the next. `merge` subscribes to every observable available to it and emits items as they come. In that way, `merge` is similar to the flattening part of `flatMap`.
324
324
325
325
Like other combinators that are static methods, `merge` has an alternative that allows you to merge sequences one by one in a chain. The operator is called `mergeWith` and the behaviour is the same. The following example has the same result as the one above.
326
326
@@ -444,7 +444,7 @@ Observable.switchOnNext(
444
444
2
445
445
```
446
446
447
-
This example may be a bit confusing. What we've done is create an observable that creates a new observable every 100ms. Every created observable emits it's number in the sequence every 30ms. After 100ms, each of those observables has had enough time to emit its number 3 times. Then a new observable is created, which causes them to be replaced by the new one.
447
+
This example may be a bit confusing. What we've done is creating an observable that creates a new observable every 100ms. Every created observable emits its number in the sequence every 30ms. After 100ms, each of those observables has had enough time to emit its number 3 times. Then a new observable is created, which causes them to be replaced by the new one.
448
448
449
449
#### switchMap
450
450
@@ -661,7 +661,7 @@ Right emits
661
661
3 - 2
662
662
```
663
663
664
-
As we can see, ``combineLatest` first it waits for every sequence to have a value. After that, every value emitted by either observable results in a combined value being emitted.
664
+
As we can see, `combineLatest` first it waits for every sequence to have a value. After that, every value emitted by either observable results in a combined value being emitted.
665
665
666
666
Just like every combinator we've seen in this chapter, there are overloads that allow to combine more than two sequences.
0 commit comments