Created
October 25, 2019 18:49
-
-
Save traviskaufman/25e0b59408ce6a3e8ba1255180959438 to your computer and use it in GitHub Desktop.
Demystifying RxJS, Part II: Custom operators
This file contains 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
function computeSquaredSum(): OperatorFunction<number, number> { | |
return source => | |
source.pipe( | |
map(n => n * n), | |
reduce((s, n) => s + n, 0), | |
); | |
} | |
oneThroughTen | |
.pipe(computeSquaredSum()) | |
.subscribe(x => console.log("Squared sum w/ custom op =", x)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment