How to publish events from callbacks (from external site) and consume them via RX linq query

Unanswered How to publish events from callbacks (from external site) and consume them via RX linq query

  • Saturday, February 09, 2013 5:54 PM
     
     

    Hello,

    I have a class, which has 3 methods (Callbacks) which receives some information which i want to publish, then consume via a linq to rx (write a simple group by even)

    Class MyClass

    {

    string A;

    string B;

    string C;

    }

    public void AddMe(string A,string B, string C)

    {

    create a object of class MyClass and publish

    }

    public void DeleteMe(string A,string B, string C)

    {

    create a object of class MyClass and publish

    }

    I want to create 2 subscriber who listen to them and first do a group by on A and second do a group by A and B

    and print count of C with key

    I am unable to understand how can i do it. Any code sample will be greatly appreciated. (these methods, publishers and consumers are in same application)

    Thanks Dave Sutton for it.

    Need to create

    public IObservable<MyClass> AlarmStream
            {
                get { return memberAdded.AsObservable(); }
            }

            private Subject<MyClass> memberAdded = new Subject<MyClass>();

    then you can use the above published stream in the main class to write linq queries.

    I was using Observable.ForEach in my action, so I was never able to go to 2nd query. Right thing was Observable.ForEachAsync

    • Edited by babooraj Saturday, February 09, 2013 6:00 PM Added more clarity
    • Edited by babooraj Saturday, February 09, 2013 9:03 PM Little progress then big stop
    • Edited by babooraj Wednesday, February 13, 2013 8:02 PM Issue Solved - My ignorance and My Coding mistakes
    •  

All Replies

  • Monday, February 11, 2013 11:16 AM
     
     

    Hi Babooraj,

    You have two types above that I think may be the same thing (MyClass vs AlarmEvent). If they are not then I don't understand your code, and I am not able to help. Your question seems related to GroupBy but you dont have a groupBy in your post.

    Can you write up a small working sample of your code and point out the parts that fail. 

    Lee


    Lee Campbell http://LeeCampbell.blogspot.com