Rxjs - Operators - FindIndex

Signature

export declare function findIndex<T>(
predicate: (value: T, index: number, source: Observable<T>) => boolean,
thisArg?: any): Observable<number>;

接受一个filter的方法
符合条件的那个元素的index会返回

var clicks = Rx.Observable.fromEvent(document, 'click');
var result = clicks.findIndex(ev => ev.target.tagName === 'IMG');
result.subscribe(
x => console.log(x),
err => console.log(err),
() => console.log("complete"));

返回后会立刻结束流