Rx: Piecing together multiple IObservable web requests

Posted by McLovin on Stack Overflow See other posts from Stack Overflow or by McLovin
Published on 2010-04-05T21:25:17Z Indexed on 2010/04/05 21:33 UTC
Read the original article Hit count: 430

Hello,

I'm creating multiple asynchronous web requests using IObservables and reactive extensions.

So this creates observable for "GET" web request:

            var tweetObservalue =
            from request in WebRequestExtensions.CreateWebRequest(outUrl + querystring, method)
            from response in request.GetResponseAsync()
            let responseStream = response.GetResponseStream()
            let reader = new StreamReader(responseStream)
            select reader.ReadToEnd();

And I can do

tweetObservable.Subscribe(response => dosomethingwithresponse(response));

What is the correct way of executing multiple asynchronous web requests with IObservables and LINQ that have to wait until other requests have been finished?

For example first I would like to verify user info: create userInfoObservable, then if user info is correct I want to update stats so I get updateStatusObservable then if status is updated I would like create friendshipObservable and so on.

Also bonus question, there is a case where I would like to execute web calls simultaneously and when all are finished execute another observable which will until other calls are finished.

Thank you.

© Stack Overflow or respective owner

Related posts about iobservable

Related posts about reactive-extensions