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.55 KB

lastindexof.md

File metadata and controls

73 lines (58 loc) · 2.55 KB

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

Returns the last 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 last 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(1,2,3,1,2,3)
  .lastIndexOf(3);

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

// => Next: 5
// => Completed

/* With an index */
var source = Rx.Observable.of(1,2,3,1,2,3)
  .lastIndexOf(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: 5
// => Completed

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests: