Skip to content

Instantly share code, notes, and snippets.

@darkyelox
Last active April 27, 2018 19:11
Show Gist options
  • Select an option

  • Save darkyelox/99437adb9aa61c6f4f0f3757f8f49a20 to your computer and use it in GitHub Desktop.

Select an option

Save darkyelox/99437adb9aa61c6f4f0f3757f8f49a20 to your computer and use it in GitHub Desktop.
Rx.Observable.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) // defines a stream of numbers
.filter(num => num % 2 == 0) // filter by pair numbers
.map(num => num * 2) // multiply each number by two
.takeLast(3) // take only the last 3 number of the stream
.map(num => `i'm the number ${num}`) // convert each number to an string
.subscribe(num => console.log(num)) // subscribes and prints each number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment