concept resultSelector in category .net

appears as: resultSelector
Rx.NET in Action

This is an excerpt from Manning's book Rx.NET in Action.

The overloads for the SelectMany operator that accept a resultSelector function are shown in the following code snippet. For each item in every collection, the resultSelector function is invoked, together with the source element that generates the collection. The value returned from resultSelector is the value that the resulting observable emits. The resultSelector in the second overload also receives the index of the emitted notification.

As with observables of enumerables, when applying the SelectMany operator on an observable of observables, you can specify a resultSelector function that will be invoked for each notification (regardless of which observable originates the notification), together with the source item that creates the observable that emits the notification (figure 8.8). This allows you to track the connection between the notifications and their origin and to produce a value based on the results. For example, for chat messages that are emitted concurrently from multiple chat rooms, it’s important to know what the source chat room is so you can show it on screen or highlight it if it’s a room of importance to the user.

Figure 8.8. When the SelectMany operator is applied to an observable of observables, the resultSelector will be invoked for each notification, together with the source item that created the observable it was emitted from.