-
以MJRefresh为例
extension Reactive where Base: MJRefreshComponent {
/// 正在刷新
var qs_refreshing: ControlEvent<Void> {
let source: Observable<Void> = Observable.create {
[weak control = self.base] observer -> Disposable in
MainScheduler.ensureExecutingOnScheduler()
guard let control = control else {
observer.on(.completed)
return Disposables.create()
}
control.refreshingBlock = {
observer.on(.next(()))
}
return Disposables.create()
}
.takeUntil(deallocated)
return ControlEvent(events: source)
}
}
网友评论