let - 2

RxJS 5 let

by Brian Troncone

HTML

<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script>

JavaScript

//emit array as a sequence
const source = Rx.Observable.from([1,2,3,4,5]);

//let provides flexibility to add multiple operators to source observable then return
const subscribeTwo = source
   .map(val => val + 1)
   .let(obs => obs
      .map(val => val + 2)
      //also, just return evens
      .filter(val => val % 2 === 0)
    )
    //output: 4,6,8
  .subscribe(val => console.log('let WITH MULTIPLE OPERATORS: ', val));