Some RX extensions I have created

Showing 1-2 of 2 messages
Some RX extensions I have created Sergey A 6/3/11 10:39 AM
Maybe this is not a right place to submit these, but please forgive me
- I'm new to open source ;) With these you can do sync calls in SL
like

response = Client.ExecuteAsync(request).First();

...............................................................
 public static class ObservableEx
    {
        public static IObservable<TResult> FromCallbackPattern<T,
TResult>(T param, Action<T, Action<TResult>> asyncCall)
        {
            return Observable
                .Create<TResult>(observer =>
                {
                    var subscribed = true;
                    asyncCall(param, value =>
                    {
                        if (!subscribed) return;
                        observer.OnNext(value);
                        observer.OnCompleted();
                    });
                    return () =>
                    {
                        subscribed = false;
                    };
                });
        }

        public static IObservable<string> ExecuteAsync(this RestClient
client, RestRequest request)
        {
            Action<RestRequest, Action<RestResponse>> callback = (r,
a) => client.ExecuteAsync(r, a);
            return FromCallbackPattern(request, callback).Select(x =>
x.Content);
        }

        public static IObservable<T> ExecuteAsync<T>(this RestClient
client, RestRequest request) where T : new()
        {
            Action<RestRequest, Action<RestResponse<T>>> callback =
(r, a) => client.ExecuteAsync(r, a);
            return FromCallbackPattern(request, callback).Select(x =>
x.Data);
        }
    }
Re: Some RX extensions I have created John Sheehan 6/3/11 8:06 PM
I haven't used Rx at all, but I think you should create a GitHub repo
for this just so it's out there for others to see if they're
interested. And then I have something I can link to when people ask
about Rx.