TakeUntil 没有按记录工作?
TakeUntil not working as documented?
来自 the docs for the TakeUntil
operator(强调我的):
The TakeUntil subscribes and begins mirroring the source Observable. It also monitors a second Observable that you provide. If this second Observable emits an item or sends a termination notification, the Observable returned by TakeUntil stops mirroring the source Observable and terminates.
如果这是真的,那为什么会阻塞?:
Observable.Never<Unit>()
.TakeUntil(Observable.Empty<Unit>())
.Wait();
Preston Guillot 在评论部分说到点子上了:
The (old) MSDN Documentation is different than the main Rx site's, and only states that TakeUntil
"Returns the values from the source observable sequence until the other observable sequence produces a value." without considering terminated observables.
让我们为Observable.TakeUntil
取一个look at the source code,特别是class O
代表“终结者”Observable
。我们可以看到 parent.OnCompleted
通知是在 O.OnNext
和 O.OnError
.
上发送的
所以您的代码阻塞的原因是 Observable.Empty
(充当“终止符”)仅发出 OnCompleted
通知。
来自 the docs for the TakeUntil
operator(强调我的):
The TakeUntil subscribes and begins mirroring the source Observable. It also monitors a second Observable that you provide. If this second Observable emits an item or sends a termination notification, the Observable returned by TakeUntil stops mirroring the source Observable and terminates.
如果这是真的,那为什么会阻塞?:
Observable.Never<Unit>()
.TakeUntil(Observable.Empty<Unit>())
.Wait();
Preston Guillot 在评论部分说到点子上了:
The (old) MSDN Documentation is different than the main Rx site's, and only states that
TakeUntil
"Returns the values from the source observable sequence until the other observable sequence produces a value." without considering terminated observables.
让我们为Observable.TakeUntil
取一个look at the source code,特别是class O
代表“终结者”Observable
。我们可以看到 parent.OnCompleted
通知是在 O.OnNext
和 O.OnError
.
所以您的代码阻塞的原因是 Observable.Empty
(充当“终止符”)仅发出 OnCompleted
通知。