Filtering operators

Filtering operators act as the where operators of any LINQ query. They reduce, take, or peek a value (or multiple values) from a sequence when messages comply with a given filtering function.

Filter

The easiest filtering operator, filter, simply applies a filtering condition that allows or prevents messages from flowing throughout the newly created sequence. In Rx, the filter operator in made by using the Where extension method like in any other LINQ query.

Filter

A marble diagram showing a filter operation

Here's an example:

var s12 = new Subject<string>(); var filtered = s12.Where(x => x.Contains("e")); filtered.Subscribe(Console.WriteLine); ...

Get Reactive Programming for .NET Developers 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.