RxSwiftDo 1.2.2

RxSwiftDo 1.2.2

tokijh 维护。



RxSwiftDo 1.2.2

  • 作者
  • tokijh

RxSwiftDo

Swift 4 Version License Platform

将简化的 Observable.do(onNext, onError ...) 转换为 Observable.do(on: Event<Value>),类似于 Observable.subscribe(on: Event<Value>)

详情

.do { (event: Event<Value>) in
    print(event)
}

OR

.do(on: { (event: Event<Value>) in
    print(event)
})

Add filter Event

.do(events: [.next, .error], on: { (event: Event<Value>) in
    print(event)
})
.do(events: [.subscribe, .subscribed]) { (event: Event<Value>) in
    print(event)
}

上一

.do(onNext: { (value) in
    print("next(\(value))")
}, onError: { (error) in
    print("error(\(error))")
}, onCompleted: {
    print("completed")
}, onSubscribe: {
    print("subscribe")
}, onSubscribed: {
    print("subscribed")
}, onDispose: {
    print("dispose")
})

事件

enum Event<Element> {
    case next(Element)  // Action to invoke for each element in the observable sequence.
    case error(Error)   // Action to invoke upon errored termination of the observable sequence.
    case completed      // Action to invoke upon graceful termination of the observable sequence.
    case subscribe      // Action to invoke before subscribing to source observable sequence.
    case subscribed     // Action to invoke after subscribing to source observable sequence.
    case dispose        // Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed.
}

事件过滤器

enum EventFilter {
    case next  // Action to invoke for each element in the observable sequence.
    case error   // Action to invoke upon errored termination of the observable sequence.
    case completed      // Action to invoke upon graceful termination of the observable sequence.
    case subscribe      // Action to invoke before subscribing to source observable sequence.
    case subscribed     // Action to invoke after subscribing to source observable sequence.
    case dispose        // Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed.
}

安装

RxSwiftDo 通过 CocoaPods 提供使用。要安装它,只需将以下行添加到您的 Podfile 中即可

pod 'RxSwiftDo'

作者

tokijh

许可证

RxSwiftDo 在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。