Skip to content

Instantly share code, notes, and snippets.

@armanozak
Created May 3, 2021 09:19
Show Gist options
  • Save armanozak/e7eb09794475c2c3bcb7cb37ee00919a to your computer and use it in GitHub Desktop.
Save armanozak/e7eb09794475c2c3bcb7cb37ee00919a to your computer and use it in GitHub Desktop.
[What's New in RxJS 7] RxJS 7 connect #blog #rxjs
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment