Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save traviskaufman/5425b330e4e000f7712309eba477e228 to your computer and use it in GitHub Desktop.
Save traviskaufman/5425b330e4e000f7712309eba477e228 to your computer and use it in GitHub Desktop.
Demystifying RxJS, Part II: Sum of Squares with pipe() / operators
const oneThroughTen = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
oneThroughTen
.pipe(
map(n => n * n),
reduce((s, n) => s + n, 0)
)
.subscribe(sqSum => console.log("Squared sum =", sqSum));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment