为什么这不会给用户带来麻烦.... [英] Why doesn't this pump the subscriber....

查看:66
本文介绍了为什么这不会给用户带来麻烦....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释为什么永远不会为这个测试方法调用以下订阅者吗?

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

我会想到的事实是完成< Unit>()方法调用返回的第二个流立即完成它将泵送CombineLatest。

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

推荐答案

您好Ollie,

Hi Ollie,

如果这是真的,那么您希望以
的形式传入什么价值? b 参数?

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

换句话说,由于右侧从不调用
OnNext 。

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

- 戴夫


这篇关于为什么这不会给用户带来麻烦....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆