first - 2

RxJS 5 first

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]);
//emit first item to pass test
const example = source.first(num => num === 5);
//output: "First to pass test: 5"
const subscribe = example.subscribe(val => console.log(`First to pass test: ${val}`));