Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(timeout): throw traceable TimeoutError #2132

Merged
merged 1 commit into from
Nov 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/operator/timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import { TimeoutError } from '../util/TimeoutError';
export function timeout<T>(this: Observable<T>, due: number | Date,
errorToSend: any = null,
scheduler: Scheduler = async): Observable<T> {
let absoluteTimeout = isDate(due);
let waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(<number>due);
return this.lift(new TimeoutOperator(waitFor, absoluteTimeout, errorToSend, scheduler));
const absoluteTimeout = isDate(due);
const waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(<number>due);
const error = errorToSend || new TimeoutError();
return this.lift(new TimeoutOperator(waitFor, absoluteTimeout, error, scheduler));
}

class TimeoutOperator<T> implements Operator<T, T> {
Expand Down Expand Up @@ -96,6 +97,6 @@ class TimeoutSubscriber<T> extends Subscriber<T> {
}

notifyTimeout(): void {
this.error(this.errorToSend || new TimeoutError());
this.error(this.errorToSend);
}
}