Skip to content

Commit

Permalink
Merge pull request #1902 from kwonoj/chore-timeoutwith
Browse files Browse the repository at this point in the history
updates signature / documents for timeoutWith
  • Loading branch information
kwonoj authored Aug 31, 2016
2 parents 6ba374e + 4013116 commit 74333eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 9 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ To reduce polymorphism and get better performance out of operators, some operato
<td><code>delay(subscriptionDelay?: Observable<any>, delayDurationSelector: function)</code></td>
<td><code>delayWhen(delayDurationSelector: function, subscriptionDelay?: Observable<any>)</code></td>
</tr>
<tr>
<td rowspan="2"><code>timeout</code></td>
<td><code>timeout(dueTime: number | Date, other?: Error, scheduler?: Scheduler)</code></td>
<td><code>timeout(due: number | Date, errorToSend?: any, scheduler?: Scheduler)</code></td>
</tr>
<tr>
<td><code>timeout(dueTime: number | Date, other?: Observable | Promise, scheduler?: Scheduler)</code></td>
<td><code>timeoutWith(due: number | Date, withObservable: ObservableInput, scheduler: Scheduler)</code></td>
</tr>
</tbody>
</table>

Expand Down
12 changes: 6 additions & 6 deletions src/operator/timeoutWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Subscriber } from '../Subscriber';
import { Scheduler } from '../Scheduler';
import { async } from '../scheduler/async';
import { Subscription, TeardownLogic } from '../Subscription';
import { Observable } from '../Observable';
import { Observable, ObservableInput } from '../Observable';
import { isDate } from '../util/isDate';
import { OuterSubscriber } from '../OuterSubscriber';
import { subscribeToResult } from '../util/subscribeToResult';
Expand All @@ -17,22 +17,22 @@ import { subscribeToResult } from '../util/subscribeToResult';
* @owner Observable
*/
export function timeoutWith<T, R>(due: number | Date,
withObservable: Observable<R>,
withObservable: ObservableInput<R>,
scheduler: Scheduler = async): Observable<T | R> {
let absoluteTimeout = isDate(due);
let waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(<number>due);
return this.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
}

export interface TimeoutWithSignature<T> {
(due: number | Date, withObservable: Observable<T>, scheduler?: Scheduler): Observable<T>;
<R>(due: number | Date, withObservable: Observable<R>, scheduler?: Scheduler): Observable<T | R>;
(due: number | Date, withObservable: ObservableInput<T>, scheduler?: Scheduler): Observable<T>;
<R>(due: number | Date, withObservable: ObservableInput<R>, scheduler?: Scheduler): Observable<T | R>;
}

class TimeoutWithOperator<T> implements Operator<T, T> {
constructor(private waitFor: number,
private absoluteTimeout: boolean,
private withObservable: Observable<any>,
private withObservable: ObservableInput<any>,
private scheduler: Scheduler) {
}

Expand Down Expand Up @@ -63,7 +63,7 @@ class TimeoutWithSubscriber<T, R> extends OuterSubscriber<T, R> {
constructor(public destination: Subscriber<T>,
private absoluteTimeout: boolean,
private waitFor: number,
private withObservable: Observable<any>,
private withObservable: ObservableInput<any>,
private scheduler: Scheduler) {
super();
destination.add(this);
Expand Down

0 comments on commit 74333eb

Please sign in to comment.