Check element in Stream
extension Observable {
public func assert(message: String = default, _ condition: (Event<E>) -> Bool) -> RxSwift.Observable<Element>
public func assertNext(message: String = default, _ condition: (E) -> Bool) -> RxSwift.Observable<Element>
}
extension Driver {
public func assert(message: String = default, _ condition: (Event<E>) -> Bool) -> RxCocoa.Driver<Element>
public func assertNext(message: String = default, _ condition: (E) -> Bool) -> RxCocoa.Driver<Element>
}
- Sample1
name
.assertNext("invalid name") { $0 != "muukii" }
.subscribe()
- Sample2
name
.assert("Don't send error") { event in
if case .Error = event {
return false
}
return true
}
.subscribe()
RxAssert is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "RxAssert"
muukii, m@muukii.me
RxAssert is available under the MIT license. See the LICENSE file for more info.