Skip to content

Instantly share code, notes, and snippets.

@rasmusvhansen
Created January 26, 2019 21:55
Show Gist options
  • Save rasmusvhansen/1d2242fe21bc823e8bf7790a045fa150 to your computer and use it in GitHub Desktop.
Save rasmusvhansen/1d2242fe21bc823e8bf7790a045fa150 to your computer and use it in GitHub Desktop.
RxJS Array Transformation
let result;
from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).pipe(
map(n => n * 2),
filter(n => n > 4),
map(n => ' Num: ' + n),
reduce((acc, str) => acc + str, 'Start:')
).subscribe(r => result = r);
console.log(result); // Start: Num: 6 Num: 8 Num: 10 Num: 12 Num: 14 Num: 16 Num: 18 Num: 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment