connect.js 613 B

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