first
signature: first(predicate: function, select: function)
first(predicate: function, select: function)단순히 첫번째 값, 혹은 조건에 맞는 첫번째 값을 발생시킵니다
예시
// RxJS v6+
import { from } from 'rxjs';
import { first } from 'rxjs/operators';
const source = from([1, 2, 3, 4, 5]);
//arguments가 없으면, 첫번째 값을 발생시킵니다
const example = source.pipe(first());
//결과: "First value: 1"
const subscribe = example.subscribe(val => console.log(`First value: ${val}`));추가 자료
Last updated
Was this helpful?