Skip to content

Commit

Permalink
Update 09_CombiningSequences.md (dotnet#2087)
Browse files Browse the repository at this point in the history
The description of a marble diagram was inconsistent with the diagram. (It had the labels `s1` and `s2` backwards.)
  • Loading branch information
MarsonShine authored Feb 28, 2024
1 parent 2305a5b commit 0e0272a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Rx.NET/Documentation/IntroToRx/09_CombiningSequences.md
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ The marble diagram below shows off usage of `CombineLatest` with one sequence th

![A marble diagram showing three sequences. The first, s1, waits for a while then produces the values 1, 2, and 3, spaced out over time. The second, s2, starts at the same time as s1, and waits for less time, producing its first value, a, before s1 produces 1. Then after s1 has produced 2, s2 produces b and then c, both being produced before s1 produces 3. The third sequence, CombineLatest, shows '1,a' at the same time as s1 produces 1, then '2,a' when s1 produces 2, then '2,b' when s2 produces b, then '2,c' when s2 produces c, then '3,c' when s1 produces 3. All three sequences do not end within the time shown in the diagram.](GraphicsIntro/Ch09-CombiningSequences-Marbles-CombineLatest-Marbles.svg)

If we slowly walk through the above marble diagram, we first see that `s1` produces the letter 'a'. `s2` has not produced any value yet so there is nothing to pair, meaning that no value is produced for the result. Next, `s2` produces the number '1' so the result sequence can now produce a pair '1,a'. We then receive the number '2' from `s1`. The last letter is still 'a' so the next pair is '2,a'. The letter 'b' is then produced creating the pair '2,b', followed by 'c' giving '2,c'. Finally the number 3 is produced and we get the pair '3,c'.
If we slowly walk through the above marble diagram, we first see that `s2` produces the letter 'a'. `s1` has not produced any value yet so there is nothing to pair, meaning that no value is produced for the result. Next, `s1` produces the number '1' so the result sequence can now produce a pair '1,a'. We then receive the number '2' from `s1`. The last letter is still 'a' so the next pair is '2,a'. The letter 'b' is then produced creating the pair '2,b', followed by 'c' giving '2,c'. Finally the number 3 is produced and we get the pair '3,c'.

This is great in case you need to evaluate some combination of state which needs to be kept up-to-date when any single component of that state changes. A simple example would be a monitoring system. Each service is represented by a sequence that returns a Boolean indicating the availability of said service. The monitoring status is green if all services are available; we can achieve this by having the result selector perform a logical AND.
Here is an example.
Expand Down Expand Up @@ -882,4 +882,4 @@ The `And`/`Then`/`When` trio has more overloads that enable you to group an even

## Summary

This chapter covered a set of methods that allow us to combine observable sequences. This brings us to a close on Part 2. We've looked at the operators that are mostly concerned with defining the computations we want to perform on the data. In Part 3 we will move onto practical concerns such as managing scheduling, side effects, and error handling.
This chapter covered a set of methods that allow us to combine observable sequences. This brings us to a close on Part 2. We've looked at the operators that are mostly concerned with defining the computations we want to perform on the data. In Part 3 we will move onto practical concerns such as managing scheduling, side effects, and error handling.

0 comments on commit 0e0272a

Please sign in to comment.