Search code examples
c#system.reactive

Can't Find Rx Dump() Method


I've seen lots of answers on here and in various posts and tutorials on other sites where the Dump() method is used on an IObservable<T> sequence. However, when I try to use it, I get a ... does not contain a definition for 'Dump' and no extension method for 'Dump' ... Cannot resolve symbol 'Dump' warning from the compiler. Has it been removed from Rx, or am I missing a library?


Solution

  • Yes I agree with the comments that it exists in LinqPad, however you may write your own as in http://www.introtorx.com/content/v1.0.10621.0/07_Aggregation.html

    public static class SampleExtentions
    {
        public static void Dump<T>(this IObservable<T> source, string name)
        {
            source.Subscribe(
               i=>Console.WriteLine("{0}-->{1}", name, i), 
               ex=>Console.WriteLine("{0} failed-->{1}", name, ex.Message),
               ()=>Console.WriteLine("{0} completed", name));
        }
    }