Created
February 4, 2018 13:43
-
-
Save dpalita/df1887033bdb23e2d18f8cb4fdfb2a61 to your computer and use it in GitHub Desktop.
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
const observableOfOddSquares = | |
// observable source | |
Observable.of( | |
// stream d'entier | |
1, 2, 3, 4, 5, 6 | |
) | |
// observer du stream d'entier, observable d'impairs | |
.filter(num => num % 2) | |
// observer du stream d'impairs, observable de carrés d'impairs | |
.map(odd => odd * odd) | |
observableOfOddSquares.subscribe( | |
// observer final du stream de carrés d'impairs | |
oddSquare => | |
console.log("I observe therefore I am", oddSquare) | |
) | |
// NB : forcément avec toutes les valeurs connues et dispo à t0 ça s'écrit bien avec un tableau (on voit le cousinage ici) | |
const arrayOfOddSquares = | |
[1, 2, 3, 4, 5, 6] | |
.filter(num => num % 2) | |
.map(odd => odd * odd) | |
arrayOfOddSquares.forEach(oddSquare => | |
console.log("I do not observe, still I am", oddSquare) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment