Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to the Rx Switch() operator?

I am working my way through the 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 references to my project, using NuGet:

System.Reactive 1.0.10621.0

System.Reactive.Windows.Forms 1.0.10621.0

I'm almost done with the labs, but I've hit a snag trying to implement the .Switch() example, Visual Studio can't locate the extension method:

'System.IObservable' does not contain a definition for 'Switch' and no extension method 'Switch' accepting a first argument of type 'System.IObservable' could be found (are you missing a using directive or an assembly reference?)

Now I know this Hands On Labs document is out of date, because certain things have been renamed (FromEvent became FromEventPattern) and certain things were removed (RemoveTimeStamp) and this document does not reflect that. For the life of me I cannot guess what they renamed Switch to be, or figure out what assembly they might have moved it to, or find a comprehensive list of release notes that indicate it was removed.

Anyone know where I can find Switch and what it's current name is?

like image 906
Jim Counts Avatar asked Jul 04 '11 14:07

Jim Counts


1 Answers

The Switch extension method doesn't extend IObservable<T> - it extends IObservable<IObservable<T>>. The full signature is:

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

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

If not, check your using namespace declarations.

like image 183
Enigmativity Avatar answered Oct 15 '22 23:10

Enigmativity