Add doOn shortcut operators
This commit is contained in:
parent
df8739fcfd
commit
0e9be4980d
|
|
@ -113,6 +113,42 @@ extension ObservableType {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Invokes an action for each Next event in the observable sequence, and propagates all observer messages through the result sequence.
|
||||
|
||||
- parameter onNext: Action to invoke for each element in the observable sequence.
|
||||
- returns: The source sequence with the side-effecting behavior applied.
|
||||
*/
|
||||
@warn_unused_result(message="http://git.io/rxs.uo")
|
||||
public func doOnNext(onNext: (E throws -> Void))
|
||||
-> Observable<E> {
|
||||
return self.doOn(onNext: onNext)
|
||||
}
|
||||
|
||||
/**
|
||||
Invokes an action for the Error event in the observable sequence, and propagates all observer messages through the result sequence.
|
||||
|
||||
- parameter onError: Action to invoke upon errored termination of the observable sequence.
|
||||
- returns: The source sequence with the side-effecting behavior applied.
|
||||
*/
|
||||
@warn_unused_result(message="http://git.io/rxs.uo")
|
||||
public func doOnError(onError: (ErrorType throws -> Void))
|
||||
-> Observable<E> {
|
||||
return self.doOn(onError: onError)
|
||||
}
|
||||
|
||||
/**
|
||||
Invokes an action for the Completed event in the observable sequence, and propagates all observer messages through the result sequence.
|
||||
|
||||
- parameter onCompleted: Action to invoke upon graceful termination of the observable sequence.
|
||||
- returns: The source sequence with the side-effecting behavior applied.
|
||||
*/
|
||||
@warn_unused_result(message="http://git.io/rxs.uo")
|
||||
public func doOnComplete(onCompleted: (() throws -> Void))
|
||||
-> Observable<E> {
|
||||
return self.doOn(onCompleted: onCompleted)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: startWith
|
||||
|
|
|
|||
Loading…
Reference in New Issue