Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Proposed Why doesn't this pump the subscriber....

  • Wednesday, February 13, 2013 2:40 PM
     
      Has Code

    Can anyone explain why the following subscriber is never called for this test method?

    I would have thought the fact the second stream returned by the Complete<Unit>() method call completes immediately it would have pumped the CombineLatest.

            [Test]
            public void should_pump()
            {
                var sync = new ManualResetEvent(false);
    
                Observable.Return(Unit.Default)
                          .CombineLatest(Complete<Unit>(), (a, b) => new { a, b })
                          .Subscribe(
                              _ =>
                                  {
                                      Debug.WriteLine("Subscriber called...");
    
                                      sync.Set();
    
                                  });
    
                Debug.WriteLine("Waiting...");
                sync.WaitOne();
            }
    
            private IObservable<T> Complete<T>()
            {
                return Observable.Create<T>(o =>
                {
                    o.OnCompleted();
                    return Disposable.Empty;
                });
            }

    ta

    Ollie


    Trying to remember what I learnt yesterday

All Replies

  • Wednesday, February 13, 2013 3:12 PM
     
     Proposed

    Hi Ollie,

    If that were true, then what value would you expect to be passed in as the b argument?

    In other words, there's nothing to combine the left side with since the right side never calls OnNext.

    - Dave


    http://davesexton.com/blog

    • Proposed As Answer by LeeCampbell Monday, February 18, 2013 10:13 AM
    •