connect.js 676 B

1234567891011121314151617
  1. import { Subject } from '../Subject';
  2. import { innerFrom } from '../observable/innerFrom';
  3. import { operate } from '../util/lift';
  4. import { fromSubscribable } from '../observable/fromSubscribable';
  5. var DEFAULT_CONFIG = {
  6. connector: function () { return new Subject(); },
  7. };
  8. export function connect(selector, config) {
  9. if (config === void 0) { config = DEFAULT_CONFIG; }
  10. var connector = config.connector;
  11. return operate(function (source, subscriber) {
  12. var subject = connector();
  13. innerFrom(selector(fromSubscribable(subject))).subscribe(subscriber);
  14. subscriber.add(source.subscribe(subject));
  15. });
  16. }
  17. //# sourceMappingURL=connect.js.map