single

연산자(operator) 정의: single(a: Function): Observable

Emit single item that passes expression.

Examples

Example 1: Emit first number passing predicate

( jsBin | jsFiddle )

//emit (1,2,3,4,5)
const source = Rx.Observable.from([1,2,3,4,5]);
//emit one item that matches predicate
const example = source.single(val => val === 4);
//output: 4
const subscribe = example.subscribe(val => console.log(val));

Additional Resources


:file_folder: Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/operator/single.ts

results matching ""

    No results matching ""