wishthis/node_modules/rxjs/dist/esm/internal/operators/connect.js

16 lines
613 B
JavaScript
Raw Normal View History

2022-06-08 10:36:39 +00:00
import { Subject } from '../Subject';
2022-07-15 07:58:48 +00:00
import { innerFrom } from '../observable/innerFrom';
2022-06-08 10:36:39 +00:00
import { operate } from '../util/lift';
import { fromSubscribable } from '../observable/fromSubscribable';
const DEFAULT_CONFIG = {
connector: () => new Subject(),
};
export function connect(selector, config = DEFAULT_CONFIG) {
const { connector } = config;
return operate((source, subscriber) => {
const subject = connector();
2022-07-15 07:58:48 +00:00
innerFrom(selector(fromSubscribable(subject))).subscribe(subscriber);
2022-06-08 10:36:39 +00:00
subscriber.add(source.subscribe(subject));
});
}
//# sourceMappingURL=connect.js.map