Created
May 3, 2021 09:19
-
-
Save armanozak/e7eb09794475c2c3bcb7cb37ee00919a to your computer and use it in GitHub Desktop.
[What's New in RxJS 7] RxJS 7 connect #blog #rxjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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