Adds optional parameter to `timer` operator.

This commit is contained in:
Krunoslav Zaher 2016-01-31 23:07:18 +01:00
parent 912e3de6e8
commit 99e5579f20
2 changed files with 3 additions and 24 deletions

View File

@ -103,7 +103,7 @@ extension Observable where Element: SignedIntegerType {
- returns: An observable sequence that produces a value after due time has elapsed and then each period.
*/
@warn_unused_result(message="http://git.io/rxs.uo")
public static func timer(dueTime: RxTimeInterval, period: RxTimeInterval, scheduler: SchedulerType)
public static func timer(dueTime: RxTimeInterval, period: RxTimeInterval? = nil, scheduler: SchedulerType)
-> Observable<E> {
return Timer(
dueTime: dueTime,
@ -113,27 +113,6 @@ extension Observable where Element: SignedIntegerType {
}
}
extension Observable where Element: SignedIntegerType {
/**
Returns an observable sequence that produces a single value at the specified absolute due time, using the specified scheduler to run the timer.
- seealso: [timer operator on reactivex.io](http://reactivex.io/documentation/operators/timer.html)
- parameter dueTime: Time interval after which to produce the value.
- parameter scheduler: Scheduler to run the timer on.
- returns: An observable sequence that produces a value at due time.
*/
@warn_unused_result(message="http://git.io/rxs.uo")
public static func timer(dueTime: RxTimeInterval, scheduler: SchedulerType)
-> Observable<E> {
return Timer(
dueTime: dueTime,
period: nil,
scheduler: scheduler
)
}
}
// MARK: take
extension ObservableType {

View File

@ -1307,12 +1307,12 @@ extension ObservableSingleTest {
errors.scan((0, nil)) { (a: (Int, NSError!), e) in
(a.0 + 1, e)
}
.flatMap { (a, e) -> Observable<Int> in
.flatMap { (a, e) -> Observable<Int64> in
if a >= 4 {
return Observable.error(e)
}
return Observable<Int>.timer(RxTimeInterval(a * 50), scheduler: scheduler)
return Observable<Int64>.timer(RxTimeInterval(a * 50), scheduler: scheduler)
}
}
}