import { merge, of } from "rxjs"; import { connect, filter, map } from "rxjs/operators"; const chars$ = of("A", "b", "C", "D", "e", "f", "G"); chars$ .pipe( connect(shared$ => merge( shared$.pipe( filter(x => x.toLowerCase() === x), map(x => `lower ${x.toUpperCase()}`) ), shared$.pipe( filter(x => x.toLowerCase() !== x), map(x => `upper ${x}`) ) ) ) ) .subscribe(console.log); // (synchronously) upper A // (synchronously) lower B // (synchronously) upper C // (synchronously) upper D // (synchronously) lower E // (synchronously) lower F // (synchronously) upper G