I am new to Rx and was going through some samples and came across the below:
Observable.FromEventPattern<RoutedEventHandler, RoutedEventArgs>(
h => new RoutedEventHandler(h),
h => Loaded += h,
h => Loaded -= h)
.Select(_ => true)
.StartWith(IsLoaded)
.Where(l => l)
.Take(1)
.Subscribe(_ => Console.WriteLine("loaded");
I am trying to deconstruct this statement to figure out what it is doing but it is not 100% clear to me.
I understand how FromEventPattern is turning the Loaded event into an observable sequence. Now, Select is going to trigger when IsLoaded is true (that is what I am assuming). Is Select just getting its info from the RoutedEventArgs?
Now, I am not sure why StartsWith is there. StartsWith will prepend a sequence of values to an observable sequence. So is it just adding the value of IsLoaded to the beginning of the list? Wouldn't it already be there after Select happens?
.Where is not applying any sort of filter so .Take will just take the first value of the sequence (which in this case is not used any further). Then it Subscribes and the Console is written to only when the control is loaded.
Is this analysis mostly correct?
Also, any tips on debugging such things (meaning, what the sequence looks like during different stages of the chain)? I can get info just by attaching the debugger but I was wondering if there are any other tricks/tips that might be commonly used.

Whereisn't necessary. - neontapir