Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Latest commit

 

History

History
73 lines (58 loc) · 2.5 KB

indexof.md

File metadata and controls

73 lines (58 loc) · 2.5 KB

Rx.Observable.prototype.indexOf(searchElement, [fromIndex])

Returns the first index at which a given element can be found in the observable sequence, or -1 if it is not present.

Arguments

  1. searchElement (Any): The value to locate in the source sequence.
  2. [fromIndex] (Number): The index to start the search. If not specified, defaults to 0.

Returns

(Observable): And observable sequence containing the first index at which a given element can be found in the observable sequence, or -1 if it is not present.

Example

/* Without an index */
var source = Rx.Observable.of(42)
  .indexOf(42);

var subscription = source.subscribe(
  function (x) {
    console.log('Next: %s', x);
  },
  function (err) {
    console.log('Error: %s', err);
  },
  function () {
      console.log('Completed');
  });

// => Next: 0
// => Completed

/* With an index */
var source = Rx.Observable.of(1,2,3)
  .indexOf(2, 1);

var subscription = source.subscribe(
  function (x) {
    console.log('Next: %s', x);
  },
  function (err) {
    console.log('Error: %s', err);
  },
  function () {
    console.log('Completed');
  });

// => Next: 0
// => Completed

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests: