What happened to the Rx Switch () operator?

I work through Hands-On-Labs for reactive extensions (Rx HOL.NET.pdf), which I downloaded from the data developer center ( here ) a few days ago.

I added these links to my project using NuGet:

System.Reactive 1.0.10621.0 System.Reactive.Windows.Forms 1.0.10621.0 

I have almost finished working with laboratories, but I fell into the trap of trying to implement the .Switch () example, Visual Studio cannot find an extension method:

'System.IObservable' does not contain a definition for 'Switch' and the extension method 'Switch' takes the first argument of type 'System.IObservable' (you don’t see the link using the directive or assembly?)

Now I know that the Hands On Labs document is deprecated because some things have been renamed ( FromEvent became FromEventPattern ) and some things have been deleted ( RemoveTimeStamp ), and this document does not reflect this. For life, I cannot guess that they renamed Switch , or find out which assembly they could transfer, or find a complete list of release notes that indicate that it was deleted.

Does anyone know where I can find Switch and what is the current name?

+6
source share
1 answer

The Switch extension method is not distributed by IObservable<T> - it extends IObservable<IObservable<T>> . Full signature:

 IObservable<TSource> Switch<TSource>(this IObservable<IObservable<TSource>> sources) 

Try Observable.Empty<IObservable<object>>(). and see if Switch appears.

If not, check your using declarations.

+8
source

Source: https://habr.com/ru/post/891967/


All Articles