Skip to content

Commit 65c5023

Browse files
committed
Merge branch 'master' into lettable-start
2 parents 762a4f9 + 4f56a61 commit 65c5023

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
<a name="5.4.3"></a>
2+
## [5.4.3](https://github.com/ReactiveX/RxJS/compare/5.4.2...v5.4.3) (2017-08-10)
3+
4+
5+
### Bug Fixes
6+
7+
* **compilation:** compiles under typescript 2.4.2 ([#2780](https://github.com/ReactiveX/RxJS/issues/2780)) ([d2a32f9](https://github.com/ReactiveX/RxJS/commit/d2a32f9))
8+
* **exports:** add exports for missing static operators: generate, ([08c4196](https://github.com/ReactiveX/RxJS/commit/08c4196))
9+
10+
11+
112
<a name="5.4.2"></a>
213
## [5.4.2](https://github.com/ReactiveX/RxJS/compare/5.4.1...v5.4.2) (2017-07-05)
314

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reactivex/rxjs",
3-
"version": "5.4.2",
3+
"version": "5.4.3",
44
"description": "Reactive Extensions for modern JavaScript",
55
"main": "index.js",
66
"config": {

src/operator/timeoutWith.ts

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,49 @@ export function timeoutWith<T, R>(this: Observable<T>, due: number | Date, withO
1515
/* tslint:enable:max-line-length */
1616

1717
/**
18-
* @param due
19-
* @param withObservable
20-
* @param scheduler
21-
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
18+
*
19+
* Errors if Observable does not emit a value in given time span, in case of which
20+
* subscribes to the second Observable.
21+
*
22+
* <span class="informal">It's a version of `timeout` operator that let's you specify fallback Observable.</span>
23+
*
24+
* <img src="./img/timeoutWith.png" width="100%">
25+
*
26+
* `timeoutWith` is a variation of `timeout` operator. It behaves exactly the same,
27+
* still accepting as a first argument either a number or a Date, which control - respectively -
28+
* when values of source Observable should be emitted or when it should complete.
29+
*
30+
* The only difference is that it accepts a second, required parameter. This parameter
31+
* should be an Observable which will be subscribed when source Observable fails any timeout check.
32+
* So whenever regular `timeout` would emit an error, `timeoutWith` will instead start re-emitting
33+
* values from second Observable. Note that this fallback Observable is not checked for timeouts
34+
* itself, so it can emit values and complete at arbitrary points in time. From the moment of a second
35+
* subscription, Observable returned from `timeoutWith` simply mirrors fallback stream. When that
36+
* stream completes, it completes as well.
37+
*
38+
* Scheduler, which in case of `timeout` is provided as as second argument, can be still provided
39+
* here - as a third, optional parameter. It still is used to schedule timeout checks and -
40+
* as a consequence - when second Observable will be subscribed, since subscription happens
41+
* immediately after failing check.
42+
*
43+
* @example <caption>Add fallback observable</caption>
44+
* const seconds = Rx.Observable.interval(1000);
45+
* const minutes = Rx.Observable.interval(60 * 1000);
46+
*
47+
* seconds.timeoutWith(900, minutes)
48+
* .subscribe(
49+
* value => console.log(value), // After 900ms, will start emitting `minutes`,
50+
* // since first value of `seconds` will not arrive fast enough.
51+
* err => console.log(err) // Would be called after 900ms in case of `timeout`,
52+
* // but here will never be called.
53+
* );
54+
*
55+
* @param {number|Date} due Number specifying period within which Observable must emit values
56+
* or Date specifying before when Observable should complete
57+
* @param {Observable<T>} withObservable Observable which will be subscribed if source fails timeout check.
58+
* @param {Scheduler} [scheduler] Scheduler controlling when timeout checks occur.
59+
* @return {Observable<T>} Observable that mirrors behaviour of source or, when timeout check fails, of an Observable
60+
* passed as a second parameter.
2261
* @method timeoutWith
2362
* @owner Observable
2463
*/

0 commit comments

Comments
 (0)