Skip to content

Latest commit

 

History

History
73 lines (57 loc) · 2.57 KB

any.md

File metadata and controls

73 lines (57 loc) · 2.57 KB

Rx.Observable.prototype.any([predicate], [thisArg])

Rx.Observable.prototype.some([predicate], [thisArg])

Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence. There is an alias to this function called some.

Arguments

  1. [predicate] (Function): A function to test each element for a condition.
  2. [thisArg] (Any): Object to use as this when executing callback.

Returns

(Observable): An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.

Example

// Without a predicate
var source = Rx.Observable.empty().any();

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

// => Next: false
// => Completed 

// With a predicate
var source = Rx.Observable.fromArray([1,2,3,4,5])
    .any(function (x) { return x % 2 === 0; });

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

// => Next: true
// => Completed 

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests: