Using Join Patterns

Let's take a look at Join pattern operators, which act like Zip on steroids (for a reminder of Zip, see Chapter 5). The Join pattern allows you to combine streams using And and Or, which lets you match many, more complicated patterns. The typical pattern is “Tell me when either of (A && B && C or D && E) happens. To make this work you'll need to use three main methods, When, And and Then.

  • When(): At the very end says “Tell me when any of the patterns happen”
  • And(): Creates a Join pattern by saying “Wait until A and B produce an item. These can be concatenated, allowing you to wait for A and B and C.
  • Then(): Once you finish combining using and, then works like select, it allows you to combine the results into a value.

The ...

Get Programming Reactive Extensions and LINQ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.