A Zip that doesn't complete when one of the observable's completes RRS feed

  • Question

  • I have a scenario where I need to kick off three different observables and I only want the subscriber to fire once all three have produced a value or completed. 2 of them come from Observable.FromAsync's so when I use a ZIP, obs2, obs3)

    The zip just completes when any of those observable complete...  So to get around this I created this

    public static IObservable<T> AsNeverComplete<T>(this IObservable<T> observable)
    			//Hack way to make ZIP not complete if a sequence completes
    			return Observable.Create<T>(observer =>
    				bool valueProduced = false;
    				return observable.Subscribe(result => 
    					valueProduced = true;
    					, observer.OnError, 
    					() =>

    Which (AFAICT) works but I was just curious if there's a different/better way to go about this?

    so now in my actual code I can do 

    var zippedObs= 
    				Observable.Zip (
    					(p1, p2, _) => 
    						//do stuff
    						return true;

    Thursday, June 2, 2016 10:24 PM