1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports['default'] = waitFor;
|
7 |
|
8 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
9 |
|
10 | var _rx = require('rx');
|
11 |
|
12 | var _rx2 = _interopRequireDefault(_rx);
|
13 |
|
14 | var _debug = require('debug');
|
15 |
|
16 | var _debug2 = _interopRequireDefault(_debug);
|
17 |
|
18 | var _utils = require('./utils');
|
19 |
|
20 | var debug = (0, _debug2['default'])('thundercats:waitFor');
|
21 | var slice = Array.prototype.slice;
|
22 |
|
23 | function waitFor() {
|
24 | return _rx2['default'].Observable.from(arguments).tapOnNext(function (observable) {
|
25 | return (0, _utils.isObservable)(observable) ? true : new Error('waitFor only take observables but got %s', observable);
|
26 | }).map(function (observable) {
|
27 | return observable.publish();
|
28 | }).tapOnNext(function (observable) {
|
29 | return observable.connect();
|
30 | }).toArray().tap(function () {
|
31 | return debug('starting waitFor');
|
32 | }).flatMap(function (arrayOfObservables) {
|
33 | return _rx2['default'].Observable.combineLatest(arrayOfObservables, function () {
|
34 | return slice.call(arguments);
|
35 | });
|
36 | }).doOnNext(function () {
|
37 | return debug('waitFor onNext!');
|
38 | });
|
39 | }
|
40 |
|
41 | module.exports = exports['default']; |
\ | No newline at end of file |