last - 3

RxJS 5 last

by Brian Troncone

HTML

<script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.8/dist/global/Rx.umd.js"></script>

JavaScript

const source = Rx.Observable.from([1,2,3,4,5]);
//supply an option projection function for the second parameter
const exampleTwo = source.last(v => v > 4, v => `The highest emitted number was ${v}`);
//output: 'The highest emitted number was 5'
const subscribeTwo = exampleTwo.subscribe(val => console.log(val));