last - 4

RxJS 5 last

by Brian Troncone

HTML

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

JavaScript

const source = Rx.Observable.from([1,2,3,4,5]);
//no values will pass given predicate, emit default
const exampleTwo = source.last(v => v > 5, v => v, 'Nothing!');
//output: 'Nothing!'
const subscribeTwo = exampleTwo.subscribe(val => console.log(val));