|
| 1 | +### `Rx.Observable.prototype.thenDo(selector)` |
| 2 | +[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/thendo.js "View in source") |
| 3 | + |
| 4 | +Matches when the observable sequence has an available value and projects the value. |
| 5 | + |
| 6 | +#### Arguments |
| 7 | +1. `selector` *(`Function`)*: Selector that will be invoked for values in the source sequence. |
| 8 | + |
| 9 | +#### Returns |
| 10 | +*(`Plan`)*: Plan that produces the projected values, to be fed (with other plans) to the when operator. |
| 11 | + |
| 12 | +#### Example |
| 13 | +```js |
| 14 | +var selector = function (x, y) { return x + ", " + y; }; |
| 15 | + |
| 16 | +var source = Rx.Observable.when( |
| 17 | + Rx.Observable.interval(250).and(Rx.Observable.of("A", "B", "C")).thenDo(selector), |
| 18 | + Rx.Observable.interval(300).and(Rx.Observable.of("a", "b")).thenDo(selector) |
| 19 | +); |
| 20 | + |
| 21 | +var subscription = source.subscribe( |
| 22 | + function (x) { |
| 23 | + console.log('Next: ' + x); |
| 24 | + }, |
| 25 | + function (err) { |
| 26 | + console.log('Error: ' + err); |
| 27 | + }, |
| 28 | + function () { |
| 29 | + console.log('Completed'); |
| 30 | + }); |
| 31 | + |
| 32 | +// => Next: 0, A |
| 33 | +// => Next: 0, a |
| 34 | +// => Next: 1, B |
| 35 | +// => Next: 1, b |
| 36 | +// => Next: 2, C |
| 37 | +// => Completed |
| 38 | +``` |
| 39 | + |
| 40 | +### Location |
| 41 | + |
| 42 | +File: |
| 43 | +- [/src/core/linq/observable/thendo.js](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/thendo.js) |
| 44 | + |
| 45 | +Dist: |
| 46 | +- [`rx.all.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.all.js) |
| 47 | +- [`rx.all.compat.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.all.compat.js) |
| 48 | +- [`rx.joinpatterns.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.joinpatterns.js) |
| 49 | + |
| 50 | +Prerequisites: |
| 51 | +- [`rx.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.js) | [`rx.compat.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.compat.js) | [`rx.lite.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.lite.js) | [`rx.lite.compat.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.lite.compat.js) |
| 52 | + |
| 53 | +NPM Packages: |
| 54 | +- [`rx`](https://www.npmjs.org/package/rx) |
| 55 | + |
| 56 | +NuGet Packages: |
| 57 | +- [`RxJS-All`](http://www.nuget.org/packages/RxJS-All) |
| 58 | +- [`RxJS-JoinPatterns`](http://www.nuget.org/packages/RxJS-JoinPatterns) |
| 59 | + |
| 60 | +Unit Tests: |
| 61 | +- [/tests/observable/when.js](https://github.com/Reactive-Extensions/RxJS/blob/master/tests/observable/when.js) |
0 commit comments