我遇到了RxSwift Scheduler的问题:
这两个代码之间有什么区别:
<div id="wap">
<div class="header">header</div>
<div class="menu">
<ul>
<li>home</li>
<li>service
<ul>
<li> a</li>
<li> b</li>
</ul>
</li>
<li>about</li>
</ul>
</div>
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
<div class="footer">footer</div>
</div>
和
let results = query.flatMapLatest { query in
return search(query)
}
.observeOn(MainScheduler.instance)
答案 0 :(得分:0)
没有区别。你可以自己看看:
_ = Observable.just()
.observeOn(ConcurrentDispatchQueueScheduler.init(qos: .userInitiated))
.do(onNext: {
print(Thread.current)
})
.flatMap{
Observable.just()
}
.observeOn(MainScheduler.instance)
.do(onNext: {
print(Thread.current)
})
.subscribe()
相当于:
_ = Observable.just()
.observeOn(ConcurrentDispatchQueueScheduler.init(qos: .userInitiated))
.do(onNext: {
print(Thread.current)
})
.flatMap{
Observable.just().observeOn(MainScheduler.instance)
}
.do(onNext: {
print(Thread.current)
})
.subscribe()
然而,对于subscribeOn
,可能是一个不同的故事,但它取决于您的Observable如何处理日程安排。