2018-10-09 11:59 by l4y, 68 阅读, 0 评论, 这里的保证是指,对所有的序列(Observable)而言,不论它在那个线程上产生元素,如果序列通过 如果 这部分内容在RxSwift 入门一文中介绍过。 如果调度器是并发的,Rx 的 如果你使用Rx可以证明是串行的调度器,它能够执行额外的优化。 在串行调度器的情况下, 除了当前的调度器,你也可以实现自己的调度器。 如果你想要描述立即执行工作的调度器,可以实现 如果你想要支持基于事件的操作,那么你可以实现 如果你想有周期执行的能力,你可以通过实现 上边我们提到 Rx 可以使用所有类型的调度器,但如果 Rx 可以证明调度器是串行的,那么会执行额外的优化observer.ron(.next(nextElement))将一个元素发送给观察者,那么序列在 observer.on 方法执行结束前不能发送下一个元素。.next 方法没有执行完成,序列也不能发送终止命令,如 .completed 或 .error。observeOn 和 subscribeOn 操作符将确保一切正常。observeOn 被优化为一个简单的 dispatch_async 调用。自定义调度器
ImmediateScheduler 协议。public protocol ImmediateScheduler { func schedule<StateType>(state: StateType, action: (/*ImmediateScheduler,*/ StateType) -> RxResult<Disposable>) -> RxResult<Disposable> }Scheduler 协议:public protocol Scheduler: ImmediateScheduler { associatedtype TimeInterval associatedtype Time var now : Time { get } func scheduleRelative<StateType>(state: StateType, dueTime: TimeInterval, action: (StateType) -> RxResult<Disposable>) -> RxResult<Disposable> }PeriodicScheduler 协议来通知 Rx。public protocol PeriodicScheduler : Scheduler { func schedulePeriodic<StateType>(state: StateType, startAfter: TimeInterval, period: TimeInterval, action: (StateType) -> StateType) -> RxResult<Disposable> }内置的调度器
