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
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) |
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
const fetchNews = (subject: string): Promise<News[]> => { | |
return fetch('http://newsApi?subject=' + subject) | |
// promise | |
.then(res => res.text() /* re promise ^^ */) | |
} | |
const trumpNews = fetchNews('Trump') | |
const kimNews = fetchNews('Kim Jong-Un') | |
trumpNews.then(news => readNewsAndLaugh(news)) | |
kimNews.then(news => readNewsAndLaugh(news)) | |
Promise.all(trumpNews, kimNews) |
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
const square = (operand: number): number => operand * operand | |
const four = square(2) |
NewerOlder