Observable object

The Observable object represents a push based collection.

The Observer and Objects interfaces provide a generalized mechanism for push-based notification, also known as the observer design pattern. The Observable object represents the object that sends notifications (the provider); the Observer object represents the class that receives them (the observer).

Methods

Observable methods:

Observable instance methods:

Observable Methods

<a id="amb1"></a>amb

Syntax

Propagates the observable sequence that reacts first.

Rx.Observable.amb(args...)
Rx.Observable.amb(sources)

Parameters

  • sources

> Required Array** - Observable sources competing to react first.

Return Value

An observable sequence that surfaces any of the given sequences, whichever reacted first.

Example

The amb method can use the form of either an array of Observable sequences or arguments of Observable sequences. In the first example, this the observable sequence will be bar which reacts first.

var obs = Rx.Observable.amb(
	Rx.Observable.timer(500).select(function () { return 'foo'; }),
	Rx.Observable.timer(200).select(function () { return 'bar'; })
);

obs.subscribe( function (x) {
	console.log(x);
});

=> bar

Alternatively, an array can be provided of Observable sequences with the same example.

var obs = Rx.Observable.amb([
	Rx.Observable.timer(500).select(function () { return 'foo'; }),
	Rx.Observable.timer(200).select(function () { return 'bar'; })
]);

obs.subscribe( function (x) {
	console.log(x);
});

=> bar

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="catchException1"></a>catchException

Continues an observable sequence that is terminated by an exception with the next observable sequence. The sources can be either an array of Observable sequences or arguments of Observable sequences.

Syntax

Rx.Observable.catchException(args...)
Rx.Observable.catchException(sources)

Parameters

  • sources

> Required Array** - Observable sequences to catch exceptions for as either an array or arguments.

Return Value

An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.

Example

var obs1 = Rx.Observable.throwException(new Error('error'));
var obs2 = Rx.Observable.returnValue(42);

var obs3 = Rx.Observable.catchException(obs1, obs2);

obs3.subscribe( function (x) {
    console.log(x);
});

=> 42

Alternatively, an array can be supplied instead of arguments.

var obs1 = Rx.Observable.throwException(new Error('error'));
var obs2 = Rx.Observable.returnValue(42);

var obs3 = Rx.Observable.catchException([obs1, obs2]);

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="concat1"></a>concat

Concatenates all of the specified observable sequences, as long as the previous observable sequence terminated successfully.

Syntax

Rx.Observable.concat(args...)
Rx.Observable.concat(sources)

Parameters

  • sources

> Required Array** - Observable sequences to concatenate.

Return Value

An observable sequence that contains the elements of each given sequence, in sequential order.

Example

The following example illustrates concatenating two observable sequences using the Rx.Observable.concat method.

var source1 = Rx.Observable.returnValue(42);
var source2 = Rx.Observable.returnValue(56);

var obs = Rx.Observable.concat(source1, source2);

obs.subscribe( function (x) {
	console.log(x);
});

=> 42, 56

Alternatively, an array can be supplied instead of arguments.

var source1 = Rx.Observable.returnValue(42);
var source2 = Rx.Observable.returnValue(56);

var obs = Rx.Observable.concat([source1, source2]);

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="create"></a>create

Creates an observable sequence from a specified subscribe method implementation.

Syntax

Rx.Observable.create(subscribe)

Parameters

  • subscribe

> Required Function** - Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in an Disposable.

Example

The following example illustrates wrapping an event by using the create method.


function fromEvent (element, eventName) {
	return Rx.Observable.create( function (observer) {
	
		// Create handler function to handle onNext calls
		function handler (e) {
			observer.onNext(e);
		}

		element.addEventListener(eventName, handler, false);

		// The disposable function removes the handler
		return function () {
			element.removeEventListener(eventName, handler, false);
		};
	});
}

fromEvent(document, 'mousemove')
	.subscribe(function (e) {
		/* Handle mouse movements */
	});

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="createWithDisposable"></a>createWithDisposable

Creates an observable sequence from a specified Subscribe method implementation.

Syntax

Rx.Observable.createWithDisposable(subscribe)

Parameters

  • subscribe

> Required Function** - Implementation of the resulting observable sequence's subscribe method.

Return Value

The observable sequence with the specified implementation for the subscribe method.

Example

The following example illustrates the createWithDisposable method by creating another observable sequence from an interval of every 500 milliseconds. After five iterations of yielding a value by observer.onNext, the sequence is ended by calling observer.onCompleted().


var obs1 = Rx.Observable.interval(500 /* ms */);

var obs2 = Rx.Observable.createWithDisposable( function (observer) {

	var count = 0;

	return obs1.subscribe( function (i) {
		observer.onNext(count);

		if (++count === 5) {
			observer.onCompleted();
		}
	});
});

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="defer"></a>defer

Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.

Syntax

Rx.Observable.defer(observableFactory)

Parameters

  • observableFactory

> Required Function** - Observable factory function to invoke for each observer that subscribes to the resulting sequence.

Return Value

An observable sequence whose observers trigger an invocation of the given observable factory function.

Example

The following example illustrates the defer method which returns an observable sequence of a single value of 42. The single value is deferred in creation until subscribe is called.

var obs = Rx.Observable.defer( function () {
	return Rx.Observable.returnValue(42);
});

obs.subscribe( function (x) {
	console.log(x);
});

=> 42

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="doWhile"></a>doWhile

Repeats the given source as long as the specified source holds, where the condition is evaluated after each repeated source completed.

Syntax

obs.doWhile(condition);

Parameters

  • condition

> Required Function** - Condition that will be evaluated upon the completion of an iteration through the source, to determine whether repetition of the source is required.

Return Value

The observable sequence obtained by concatenating the source sequence as long as the condition holds.

Example

var i = 0;
var range = Rx.Observable.range(0, 10);

var obs = range.doWhile( function () {
	return ++i < 3;
});

obs.subscribe( function (x) {
	console.log(x);
});

=> 1, 2

Dependencies

Files:

- rx.js
- rx.exprimental.js

NPM:

- rx module

NuGet:

- RxJS-Experimental

<a id="forIn"></a>forIn

Concatenates the observable sequences obtained by running the resultSelector for each element in the given array.

Syntax

Rx.Observable.forIn(source, resultSelector)

Parameters

  • source

> Required Array** - Array source for which each element will be mapped onto an observable source that will be concatenated in the result sequence.
  • resultSelector

> Required Function** - Function to select an observable source for each element in the source.

Return Value

The observable sequence obtained by concatenating the sources returned by resultSelector for each element in the source.

Example

var arr = [1,2,3];

var obs = Rx.Observable.forIn(arr, function (x) {
	return x * x;
});

obs.subscribe( function (x) {
	console.log(x);
});

x => 1, 4, 9

Dependencies

Files:

- rx.js
- rx.exprimental.js

NPM:

- rx module

NuGet:

- RxJS-Experimental

<a id="forkJoin1"></a>forkJoin

Runs all specified observable sequences in parallel and collects their last elements.

Syntax

Rx.Observable.forkJoin(args...);
Rx.Observable.forkJoin(sources);

Parameters

  • sources

> Required Array** - Observable sequence to collect the last elements for.

Return Value

An observable sequence with an array collecting the last elements of all the input sequences.

Example

The following example illustrates the forkJoin method by combining two observable sequences. This produces an array with the yielded values in order.

var source1 = Rx.Observable.returnValue(42);
var source2 = Rx.Observable.returnValue(56);

var obs = Rx.Observable.forkJoin(source1, source2);

var sub = obs.subscribe( function (x) {
	for (var i = 0, len = x.length; i < len; i++) {
		console.log(x);
	}
});

=> 42, 56

Alternatively, the arguments to forkJoin can be specified as an array.

var source1 = Rx.Observable.returnValue(42);
var source2 = Rx.Observable.returnValue(56);

var obs = Rx.Observable.forkJoin([source1, source2]);

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Experimental

<a id="fromArray"></a>fromArray

Converts an array to an observable sequence, using the specified scheduler to run the enumeration loop.

Syntax

Rx.Observable.fromArray(source, [scheduler]);

Parameters

  • source

> Required Array** - Array to convert to an observable sequence.
  • scheduler

> Optional Scheduler** - An optional scheduler to run the enumeration of the input sequence on. If not specified, defaults to Rx.Scheduler.currentThread.

Return Value

The observable sequence whose elements are pulled from the given array.

Example

The following example shows the fromArray method which takes an array with three elements and converts it to an observable sequence.

var obs = Rx.Observable.fromArray([1,2,3]);

var sub = obs.subscribe( function (x) {
	console.log(x);
});

=> 1, 2, 3

Optionally, a Scheduler can be specified, for example using the TimeoutScheduler.

var obs = Rx.Observable.fromArray([1,2,3], Rx.Scheduler.timeout);

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="generate"></a>generate

Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the optional scheduler to send out observer messages.

Syntax

Rx.Observable.generate(initialState, condition, iterate, resultSelector, [scheduler]);

Parameters

  • initialState

> Required Any** - Initial state.
  • condition

> Required Function** - Condition to terminate generation (upon returning false).
  • iterate

> Required Function** - Iteration step function.
  • resultSelector

> Required Function** - Selector function for results produced in the sequence.
  • scheduler

> Optional Scheduler** - Optional scheduler on which to run the generator loop. If not specified, defaults to Rx.Scheduler.currentThread.

Return Value

The generated sequence.

Example

var obs = Rx.Observable.generate(
	0, 				// Initial State
	function (x) {  // Condition
		return x < 10;
	},
	function (x) {	// Iterate
		return x + 1;
	},
	function (x) {  // Result Selector
		return x;
	});

var sub = obs.subscribe( function (x) {
	console.log(x);
});

=> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="generateWithAbsoluteTime"></a>generateWithAbsoluteTime

Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements, using the specified scheduler to run timers and to send out observer messages.

Syntax

Rx.Observable.generateWithAbsoluteTime(initialState, condition, iterate, resultSelector, timeSelector, [scheduler]);

Parameters

  • initialState

> Required Any** - Initial state.
  • condition

> Required Function** - Condition to terminate generation (upon returning false).
  • iterate

> Required Function** - Iteration step function.
  • resultSelector

> Required Function** - Selector function for results produced in the sequence.
  • timeSelector

> Required Function** - Time selector function to control the speed of values being produced each iteration.
  • scheduler

> Optional Scheduler** - Optional scheduler on which to run the generator loop. If not specified, defaults to Rx.Scheduler.currentThread.

Return Value

The generated sequence.

Example

The following example illustrates creating an observable sequence generated using an absolute time via Date to schedule yield items at the specified time.

var obs = Rx.Observable.generate(
	0, 				// Initial State
	function (x) {  // Condition
		return x < 10;
	},
	function (x) {	// Iterate
		return x + 1;
	},
	function (x) {	// Result Selector
		return x;
	},
	function (x) {	// Time selector
		return new Date(new Date() + (x * 1000));
	});

var sub = obs.subscribe( function (x) {
	console.log(x);
});

=> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

<a id="generateWithRelativeTime"></a>generateWithRelativeTime

Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements, using the specified scheduler to run timers and to send out observer messages.

Syntax

Rx.Observable.generateWithRelativeTime(initialState, condition, iterate, resultSelector, timeSelector, [scheduler]);

Parameters

  • initialState

> Required Any** - Initial state.
  • condition

> Required Function** - Condition to terminate generation (upon returning false).
  • iterate

> Required Function** - Iteration step function.
  • resultSelector

> Required Function** - Selector function for results produced in the sequence.
  • timeSelector

> Required Function** - Time selector function to control the speed of values being produced each iteration.
  • scheduler

> Optional Scheduler** - Optional scheduler on which to run the generator loop. If not specified, defaults to Rx.Scheduler.currentThread.

Return Value

The generated sequence.

Example

The following example illustrates creating an observable sequence generated using a relative time to schedule yield items at the specified time.

var obs = Rx.Observable.generate(
	0, 				// Initial State
	function (x) {  // Condition
		return x < 10;
	},
	function (x) {	// Iterate
		return x + 1;
	},
	function (x) {	// Result Selector
		return x;
	},
	function (x) {	// Time selector
		return x * 1000 /* ms */; 
	});

var sub = obs.subscribe( function (x) {
	console.log(x);
});

=> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

<a id="ifThen"></a>ifThen

If the specified condition evaluates true, select the thenSource sequence. Otherwise, select the optional elseSource sequence or an empty sequence with the specified scheduler.

Syntax

Rx.Observable.ifThen(condition, thenSource);

Rx.Observable.ifThen(condition, thenSource, elseSource);

Rx.Observable.ifThen(condition, thenSource, scheduler);

Parameters

  • condition

> Required Function** - Condition evaluated to decide which sequence to return.
  • thenSource

> Required Observable** - Sequence returned in case the condition evaluates true.
  • elseSource

> Optional Observable** - Sequence returned in case the condition evaluates false.
  • scheduler

> Optional Scheduler** - Scheduler to generate an empty sequence on in case the condition evaluates false.

Example

The first example illustrates the ifThen method which will yield 42 if the current Date is divisible by 2 else an empty observable sequence.

var source1 = Rx.Observable.returnValue(42);

var obs = Rx.Observable.ifThen(
	function () {
		return new Date() % 2 === 0;
	},
	source1);

The next example specifies an else sequence which is yielded if the condition returns false.

var source1 = Rx.Observable.returnValue(42);
var source2 = Rx.Observable.returnValue(56);

var obs = Rx.Observable.ifThen(
	function () {
		return new Date() % 2 === 0;
	},
	source1,
	source2);

Finally, a scheduler can also be specified to parameterize the concurrency of the empty else sequence.

var source1 = Rx.Observable.returnValue(42);

var obs = Rx.Observable.ifThen(
	function () {
		return new Date() % 2 === 0;
	},
	source1,
	Rx.Scheduler.timeout);

Dependencies

Files:

- rx.js
- rx.experimental.js

NPM:

- rx module

NuGet:

- RxJS-Experimental

<a id="interval"></a>interval

Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.

Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification. If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the current one has been handled. In case you need to control the time between the end and the start of consecutive notifications, consider using the generateWithRelativeTime operator instead.

Syntax

Parameters

  • period

> Required Number** - Period for producing the values in the resulting sequence. If this value is equal to zero, the timer will recur as fast as possible.
  • scheduler

> Optional Scheduler** - Optional scheduler to run the timer on.

Return Value

An observable sequence that produces a value after each period.

Example

The following example creates an observable sequence which yields an incrementing value each second.

var obs = Rx.Observable.interval(1000 /* ms */);

Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

<a id="merge1"></a>merge

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="never"></a>never

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="onErrorResumeNext1"></a>onErrorResumeNext

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="range"></a>range

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="repeat1"></a>repeat

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="returnValue"></a>returnValue

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="start"></a>start

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="switchCase"></a>switchCase

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="timer"></a>timer

Syntax

Parameters

Example

Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

<a id="toAsync"></a>toAsync

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="when"></a>when

Syntax

Parameters

Example

Dependencies

Files:

- rx.js
- rx.joinpatterns.js

NPM:

- rx module

NuGet:

- RxJS-JoinPatterns

<a id="whileDo"></a>whileDo

Syntax

Parameters

Example

Dependencies

Files:

- rx.js
- rx.experimental.js

NPM:

- rx module

NuGet:

- RxJS-Experimental

Observable Instance Methods

<a id="aggregate"></a>aggregate

Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.

For aggregation behavior with incremental intermediate results, see scan method.

Syntax

obs.aggregate([seed], accumulator)

Parameters

  • seed
> Optional Object** - The initial accumulator value.
  • accumulator
> Required Function** - An accumulator function to be invoked on each element.

Return value

An observable sequence containing a single element with the final accumulator value.

Example

The following example illustrates the aggregate function called without a seed.
/* Without seed */
var obs = Rx.Observable
    .range(0, 10)
    .aggregate( function (acc, x) { 
        return acc + x;
    });

The following example provides a seed of 10 as the initial accumulate.
/* With seed */
var obs = Rx.Observable
    .range(0, 10)
    .aggregate(10, function (acc, x) { 
        return acc + x;
    });

Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

<a id="all"></a>all

Determines whether all elements of an observable sequence satisfy a condition.

Syntax

obs.all(predicate)

Parameters

  • predicate
> Required Function** - A function to test each element for a condition.

Return Value

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

Example

The following example tests whether all items are greater than 3.

var observable = Rx.Observable
	.fromArray([4, 6, 8])
	.all( function (x) {
		return x > 3;
	});

Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

<a id="amb2"></a>amb

Propagates the observable sequence that reacts first.

Syntax

obs.amb(second)

Parameters

  • second
> Required Observable** - Second observable sequence.

Return Value

An observable sequence that surfaces either of the given sequences, whichever reacted first.

Example

The following example illustrates the amb method which selects the obs2 as the sequence which will react first.

var obs1 = Rx.Observable.timer(500);
var obs2 = Rx.Observable.timer(300);

var obs3 = obs1.amb(obs2);

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="and"></a>and

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-JoinPatterns

<a id="any"></a>any

Determines whether any element of an observable sequence satisfies a condition if provided, else if there are any items in the sequence.

Syntax

obs.any([predicate])

Parameters

  • predicate
> Optional Funciton** - A function to test each element for a condition

Return Value

An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate.

Example

The following example demonstrates the any method without a predicate. In this instance, the sequence is empty and will return an observable sequence with a single value of false.

var obs = Rx.Observable.empty.any();
obs.subscribe( function (a) {
	console.log(a); // false
});

The next example demonstrates the any method with a supplied predicate. This instance will return an observable sequence with a single value of true as there are values that equal 2.

var obs = Rx.Observable
	.fromArray([1,2,3])
	.any( function (x) {
		return x === 2;
	});
obs.subscribe( function (a) {
	console.log(a); // true
});

Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

<a id="asObservable"></a>asObservable

Hides the identity of an observable sequence.

Syntax

obs.asObservable()

Return Value

An observable sequence that hides the identity of the source sequence.

Example

The following example hides the identity of an Subject.

var subject = new Rx.Subject();
var obs = subject.asObservable();

console.log(subject === obs);

=> false

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="average"></a>average

Computes the average of an observable sequence of values that are obtained by invoking an optional transform function on each element of the input sequence.

Syntax

obs.average([selector]);

Parameters

  • selector
> Optional Function** - A transform function to apply to each element.

Return Value

An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

Example

The following example demonstrate which computes the average of a given observable sequence.

var obs = Rx.Observable.fromArray([1,2,3]);
var avg = obs.average();

avg.subscribe( function (a) {
	console.log(a);
});

=> 2

The next example demonstrates using a selector to project the value to be averaged.

var arr = [{name: 'abc', count: 1}, {name: 'def', count: 3}];
var obs = Rx.Observable.fromArray(arr);
var avg = obs.average( function (x) {
	return x.count;
});

avg.subscribe( function (a) {
	console.log(a);
});

=> 2

Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

<a id="buffer"></a>buffer

Syntax

Parameters

Example

Dependencies

Files:

- rx.js
- rx.coincidence.js

NPM:

- rx module

NuGet:

- RxJS-Coincidence

<a id="bufferWithCount"></a>bufferWithCount

Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.

Syntax

obs.bufferWithCount(count, [skip])

Parameters

  • count
> Required Number** - Length of each buffer.
  • skip
> Optional Number** - Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.

Return Value

An observable sequence of buffers.

Example

var range = Rx.Observable.range(0, 10);

range
	.bufferWithCount(2)
	.subscribe( function (x) {
		console.log(x);
	});

=>
[ 0, 1 ]
[ 2, 3 ]
[ 4, 5 ]
[ 6, 7 ]
[ 8, 9 ]

{code:javascript}
var range = Rx.Observable.range(0, 10);

range
.bufferWithCount(2,, 1)
.subscribe( function (x) {
console.log(x);
});

=>
0, 1
1, 2
2, 3
3, 4
4, 5
5, 6
6, 7
7, 8
8, 9
9

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="bufferWithTime"></a>bufferWithTime

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

!! <a id="bufferWithTimeOrCount"></a>bufferWithTimeOrCount

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

!! <a id="catchException2"></a>catchException

Continues an observable sequence that is terminated by an exception with the next observable sequence or handler which returns an observable sequence.

!!! Syntax

obs.catchException(handler)
obs.catchException(second)

!!! Parameters

* handler
> _Required_ *Function* - Exception handler function that returns an observable sequence given the error that occurred in the first sequence

* second
> _Required_ *Observable* - A second observable sequence used to produce results when an error occurred in the first sequence.

!!! Return Value

An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.

!!! Example

The following example illustrates the catchException method with a handler function.

var error = new Error('Exception');
var obs1 = Rx.Observable.throwException(error);
var obs2 = obs1
.catchException( function (e) {
return Rx.Observable.returnValue('Error: ' + e);
});

The next example illustrates the catchException method with a second observable.

var error = new Error('Exception');
var obs1 = Rx.Observable.throwException(error);
var obs2 = Rx.Observable.returnValue(42);

var obs3 = obs1.catchException(obs2);

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="combineLatest"></a>combineLatest

Merges the observable sequences into one observable sequence by using the selector function whenever one of the observable sequences produces an element.

!!! Syntax

obs.combineLatest(... Observable args, resultSelector);

!!! Parameters

* Observable args
> _Required_ **Observable** - Observable sources.

* resultSelector
> _Required_ **Function** - Function to invoke whenever either of the sources produces an element.

!!! Return Value

An observable sequence containing the result of combining elements of all sources using the specified result selector function.

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="concat2"></a>concat

Concatenates the second observable sequence to the first observable sequence upon successful termination of the first.

!!! Syntax

obs.concat(second)

!!! Parameters

* second
> _Required_ *Observable* - Second observable sequence.

!!! Return Value

An observable sequence that contains the elements of the first sequence, followed by those of the second the sequence.

!!! Example

The following example illustrates using the concat method to concatenate the second observable to the first.

var obs1 = Rx.Observable.returnValue(1);
var obs2 = Rx.Observable.returnValue(2);

var obs3 = obs1.concat(obs2);

obs3.subscribe( function (x) {
console.log(x);
});

=> 1 2

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="contains"></a>contains

Determines whether an observable sequence contains a specified element with an optional equality comparer function.

!!! Syntax

obs.contains(value, comparer)

!!! Parameters

* value
> _Required_ **Object** - The value to locate in the source sequence.

* comparer
> _Optional_ **Function** - An equality comparer to compare elements.

!!! Return Value

An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.

!!! Example

The following example demonstrates the contains method without a specified comparer.

var obs = Rx.Observable.fromArray(1,2,3);
var con = obs.contains(2);

con.subscribe( function (x) {
console.log(x);
});

=> true

The next example demonstrates using a custom equality comparer.

var arr = {name: 'abc'}, {name: 'def'};
var obs = Rx.Observable.fromArray(arr);
var con = obs.contains({name: 'abc'}, function (x, y) {
return x.name === y.name;
});

con.subscribe( function (x) {
console.log(x);
});

=> true

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="count"></a>count

Returns an observable sequence containing a number that represents how many elements in the specified observable sequence satisfy a condition if supplied else the number of items in the observable sequence.

!!! Syntax

obs.count(predicate)

!!! Parameters

* predicate

  > _Optional_ **Function** - An optional function to test each element for a condition.

!!! Return Value

An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if supplied, else the number of items in the observable sequence.

!!! Example

The following example demonstrates the count function where the predicate is not supplied.

var obs = Rx.Observable
.range(0, 10)
.count();

obs.subscribe( function (x) {
console.log(x); // 10
});

The next example demonstrates when the predicate function is supplied to determine how many in the observable sequence are greater than 5.

var obs = Rx.Observable
.range(0, 10)
.count( function (x) {
return x > 5;
});

obs.subscribe( function (x) {
console.log(x); // 4
});

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="defaultIfEmpty"></a>defaultIfEmpty

Returns the elements of the specified sequence or the type parameter's default value in a singleton sequence if the sequence is empty.

!!! Syntax

obs.defaultIfEmpty(defaultValue);

!!! Parameters

* defaultValue

  > _Optional_ **Any** - The value to return if the sequence is empty, and if not supplied the value is null.

!!! Return Value

An observable sequence that contains the default value for the TSource type if the source is empty; otherwise, the elements of the source itself.

!!! Example

var obs = Rx.Observable.empty();

var subscription = obs.defaultIfEmpty(42)
.subscribe(function (x) {
console.log(x);
});
=> 42

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="delay"></a>delay

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

!! <a id="dematerialize"></a>dematerialize

Dematerializes the explicit notification values of an observable sequence as implicit notifications.

!!! Syntax

obs.dematerialize()

!!! Return Value

An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="distinct"></a>distinct

Returns an observable sequence that contains only distinct elements according to the optional keySelector and the optional key serializer.

Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.

!!! Syntax

obs.distinct(keySelector, keySerializer);

!!! Parameters

* keySelector

  > _Optional_ **Function** - A function to compute the comparison key for each element.

* keySerializer

  > _Optional_ **Function** - Function to serialize the key.

!!! Return Value

An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.

!!! Example

The first example shows using distinct without any parameters which then yields the distinct values.

var obs = Rx.Observable.fromArray(1,2,3,3,2,1);

obs.distinct.subscribe(function (x) {
console.log(x);
});

=> 1, 2, 3

The next example uses the keySelector function to find the distinct values.

var array = {key: 1}, {key: 2}, {key: 1}, {key: 2};
var obs = Rx.Observable.fromArray(array);

var subscription = obs.distinct(function (x) { return x.key; })
.subscribe(function (x) {
console.log(x);
});

=>
{ key: 1}
{ key: 2}

The last example uses the custom key serializer to determine equality.

var array = {key: 1}, {key: 2}, {key: 1}, {key: 2};
var obs = Rx.Observable.fromArray(array);

var subscription = obs.distinct(null, function (x) { return x.key.toString(); })
.subscribe(function (x) {
console.log(x);
});

=>
{ key: 1}
{ key: 2}

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="distinctUntilChanged"></a>distinctUntilChanged

Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.

!!! Syntax

obs.distinctUntilChanged(keySelector, comparer)

!!! Parameters

* keySelector
> _Optional_ **Function** - A function to compute the comparison key for each element. If not provided, it projects the value

* comparer
> _Optional_ **Function** - Equality comparer for computed key values. If not provided, defaults to an equality comparer function.

!!! Return Value

An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.

!!! Example

var obs = Rx.Observable.fromArray(1,1,3,3,5,5,1);

obs
.disinctUntilChanged()
.subscribe( function (x) {
console.log(x);
});

=> 1 3 5 1
function comparer (e1, e2) {
return e1.clientX === e2.clientX && e1.clientY === e2.clientY;
}

function getMouseCoords (e) {
return { clientX: e.clientX, clientY: e.clientY };
}

var obs = Rx.Observable.fromEvent(document, 'mousemove');
.distinctUntilChanged(getMouseCoords, comparer)
.subscribe( function (x) {
results.innerHTML = 'X: ' + e.clientX + ' Y: ' + e.clientY;
});

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="doAction"></a>doAction

Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.

This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.


        /// &#10;
        /// &#10;1 - observable.doAction(observer);
        /// &#10;2 - observable.doAction(onNext);
        /// &#10;3 - observable.doAction(onNext, onError);
        /// &#10;4 - observable.doAction(onNext, onError, onCompleted);
        /// </summary>
        /// <param name="observerOrOnNext">Action to invoke for each element in the observable sequence or an observer.</param>
        /// <param name="onError">[Optional] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.</param>
        /// <param name="onCompleted">[Optional] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.</param>>  

!!! Syntax

obs.doAction(observer)
obs.doAction(onNext, onError, onCompleted)

!!! Parameters

* observer
> _Required_ **Observer** - Observer whose methods to invoke as part of the source sequence's observation.

Or if using functions to represent the actions

* onNext 
> _Required_ **Function** - Action to invoke for each element in the observable sequence.

* onError
> _Optional_ **Function** - Action to invoke upon exceptional termination of the observable sequence.

* onCompleted
> _Optional_ **Function** -  Action to invoke upon graceful termination of the observable sequence.

!!! Return Value

The source sequence with the side-effecting behavior applied.

!!! Example

var observer = Rx.Observer.create(
function (next) {
console.log('Next: ' + next);
},
function (error) {
console.log('Error: ' + error);
},
function () {
console.log('Completed');
});

var obs = Rx.Observable.returnValue(42)
.doAction(observer)
.subscribe();

=>
Next: 42
Completed
function oNext (next) {
console.log('Next: ' + next);
}

function onError (error) {
console.log('Error: ' + error.message);
}

function onCompleted() {
console.log('Completed');
}

var obs = Rx.Observable.throwException(new Error('Error'))
.doAction(onNext, onError, onCompleted)
.subscribe();

Error: Error

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="doWhile"></a>doWhile

Repeats the given Observable as long as the specified condition holds, where the condition is evaluated after each repeated Observable completed.

!!! Syntax

obs.doWhile(condition)

!!! Parameters

* condition
> _Required_ **Function** - Condition that will be evaluated upon the completion of an iteration through the <paramref name="source"/>, to determine whether repetition of the source is required.

!!! Return Value

The observable sequence obtained by concatenating the observable sequence as long as the condition holds.

!!! Example

The following example illustrates the doWhile function which continues the sequence until the condition is false.

var count = 0;
var obs = Rx.Observable
.interval(500 /* ms */)
.doWhile( function () {
return ++count < 5;
});

obs.subscribe (function (x) {
console.log(x);
});

=> 0 1 2 3 4

!!! Dependencies

Files:

- rx.js
- rx.experimental.js

NPM:

- rx module

NuGet:

- RxJS-Experimental

!! <a id="elementAt"></a>elementAt

Returns the element at a specified index in a sequence.

!!! Syntax

obs.elementAt(index)

!!! Parameters

* index
> _Required_ **Number** - The zero-based index of the element to retrieve.

!! Return Value

An observable sequence that produces the element at the specified position in the source sequence.

!!! Example

The following example illustrates using the elementAt to get the third item in the observable sequence.

var obs = Rx.Obervable
.range(0, 10)
.elementAt(3);

obs.subscribe( function (x) {
console.log(x);
});

=> 3

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="elementAtOrDefault"></a>elementAtOrDefault

Returns the element at a specified index in a sequence or a default value if the index is out of range.

!!! Syntax

obs.elementAtOrDefault(index, defaultValue)

!!! Parameters

* index
> _Required_ **Number** - The zero-based index of the element to retrieve.

* defaultValue
> _Optional_ **Object** - The default value if the index is outside the bounds of the source sequence.  If not supplied, the value will be null.

!!! Return Value

An observable sequence that produces the element at the specified position in the source sequence, or a default value if the index is outside the bounds of the source sequence.

!!! Example

The following example illustrates using the elementAtOrDefault to get a value

var obs = Rx.Obervable
.range(0, 10)
.elementAtOrDefault(11, -1);

obs.subscribe( function (x) {
console.log(x);
});

=> -1

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="empty"></a>empty

Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.

!!! Syntax

Rx.Observable.empty(scheduler);

!!! Parameters

* scheduler

  > _Optional_ **Scheduler** - Scheduler to send the termination call on.

!!! Return Value

An observable sequence with no elements.

!!! Example

The follow example illustrates an empty observable collection.

var obs = Rx.Observable.empty();

var subscription = obs.subscribe(
function (x) { console.log('Next'); },
function (e) { console.log('Error'); },
function () { console.log('Done'); }
);

=> Done

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="expand"></a>expand

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.experimental.js

NPM:

- rx module

NuGet:

- RxJS-Experimental

!! <a id="finallyAction"></a>finallyAction

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="first"></a>first

Returns the first element of an observable sequence that satisfies the condition in the predicate if provided, else the first element in the observable sequence.

!!! Syntax

obs.first(predicate)

!!! Parameters

* predicate
> _Optional_ **Function** - A predicate function to evaluate for elements in the source sequence.

!!! Return Value

Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if supplied, else the first element in the observable sequence.

!!! Example

The following is an example of using the first method to produce an observable sequence with the first value.

var obs = Rx.Observable
.range(0, 10)
.first();

obs.subscribe( function (x) {
console.log(x);
});

=> 0

The next example shows an error if there are no elements in the sequence.

var obs = Rx.Observable
.empty()
.first();

obs.subscribe(
function (x) {
console.log(x);
},
function (err) {
console.log('Error!');
});

=> Error!

The next example uses the predicate to find the first value greater than 5.

var obs = Rx.Observable
.fromArray(1,3,5,7,9)
.first( function (x) {
return x > 5;
});

=> 7

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="firstOrDefault"></a>firstOrDefault

Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.

!!! Syntax

obs.firstOrDefault(predicate, defaultValue)

!!! Parameters

* predicate
> _Optional_ **Function** - A predicate function to evaluate for elements in the source sequence.

* defaultValue
> _Optional_ **Any** - The default value if no such element exists.  If not specified, defaults to null.

!!! Return Value

Sequence containing the first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.

!!! Example

The following example demonstrates the firstOrDefault method supplying no default value.

var obs = Rx.Observable
.empty()
.firstOrDefault();

obs.subscribe( function (x) {
console.log(x);
});

=> null

The next example demonstrates the firstOrDefault with a default value and no predicate.

var obs = Rx.Observable
.empty()
.firstOrDefault(null, 0);

obs.subscribe( function (x) {
console.log(x);
});

=> 0

The final example is using a predicate and a default value with the firstOrDefault method.

var obs = Rx.Observable
.range(0, 5)
.firstOrDefault(function (x) { return x > 5; }, 0);

obs.subscribe( function (x) {
console.log(x);
});

=> 0

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="forkJoin2"></a>forkJoin

!!! Syntax

!!! Parameters

!!! Return Value

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.experimental.js

NPM:

- rx module

NuGet:

- RxJS-Experimental

!! <a id="groupBy"></a>groupBy

!!! Syntax

!!! Parameters

!!! Return Value

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="groupByUntil"></a>groupByUntil

!!! Syntax

!!! Parameters

!!! Return Value

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="groupJoin"></a>groupJoin

!!! Syntax

!!! Parameters

!!! Return Value

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.coincidence.js

NPM:

- rx module

NuGet:

- RxJS-Coincidence

!! <a id="ignoreElements"></a>ignoreElements

!!! Syntax

!!! Parameters

!!! Return Value

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="isEmpty"></a>isEmpty

Determines whether an observable sequence is empty.

!!! Syntax

obs.isEmpty()

!!! Return Value

An observable sequence containing a single element determining whether the source sequence is empty.

!!! Example

The following example demonstrates the isEmpty method which returns a boolean indicating whether the observable sequence is empty.

var obs1 = Rx.Observable
.returnValue(42)
.isEmpty();

obs1.subscribe( function (x) {
console.log(x);
});

=> false

var obs2 = Rx.Observable
.empty()
.isEmpty();

obs1.subscribe( function (x) {
console.log(x);
});

=> true

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="join"></a>join

!!! Syntax

!!! Parameters

!!! Return Value

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.coincidence.js

NPM:

- rx module

NuGet:

- RxJS-Coincidence

!! <a id="last"></a>last

Returns the last element of an observable sequence that satisfies the condition in the predicate is supplied, else the last element in the observable sequence.

!!! Syntax

obs.last(predicate)

!!! Parameters

* predicate
> _Optional_ **Function** - A predicate function to evaluate for elements in the source sequence.

!!! Return Value

Sequence containing the last element in the observable sequence that satisfies the condition in the predicate if supplied, else an observable with the last element in the sequence.

!!! Example

The following example illustrates the last method which returns a sequence with the last element.

var obs = Rx.Observable
.range(0, 10)
.last();

obs.subscribe( function (x) {
console.log(x);
});

=> 9

The next example shows an error if there are no elements in the sequence.

var obs = Rx.Observable
.empty()
.last();

obs.subscribe(
function (x) {
console.log(x);
},
function (err) {
console.log('Error!');
});

=> Error!

The final example demonstrates using a predicate to find the last matching element.

var obs = Rx.Observable
.fromArray(1,7,7,3,5)
.last( function (x) {
return x > 5;
});

obs.subscribe( function (x) {
console.log(x);
});

=> 7

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="lastOrDefault"></a>lastOrDefault

Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.

!!! Syntax

obs.lastOrDefault(predicate, defaultValue)

!!! Parameters

* predicate 
> _Optional_ **Function** - A predicate function to evaluate for elements in the source sequence.

* defaultValue 
> _Optional_ **Any** - The default value if no such element exists.  If not specified, defaults to null.

!!! Return Value

Sequence containing the last element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.

!!! Example

The following example demonstrates the firstOrDefault method supplying no default value.

var obs = Rx.Observable
.empty()
.lastOrDefault();

obs.subscribe( function (x) {
console.log(x);
});

=> null

The next example demonstrates the firstOrDefault with a default value and no predicate.

var obs = Rx.Observable
.empty()
.lastOrDefault(null, 0);

obs.subscribe( function (x) {
console.log(x);
});

=> 0

The final example is using a predicate and a default value with the lastOrDefault method.

var obs = Rx.Observable
.range(0, 5)
.lastOrDefault(function (x) { return x > 5; }, 0);

obs.subscribe( function (x) {
console.log(x);
});

=> 0

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="max"></a>max

Returns the maximum value in an observable sequence according to the specified comparer.

!!! Syntax

obs.max(selector)

!!! Parameters

* comparer
> _Optional_ **Function** - Comparer used to compare key values.

!!! Return Value

An observable sequence containing a single element with the maximum element in the source sequence.

!!! Example

The first example demonstrates using max to get the maximum number in a sequence.

var obs = Rx.Observable
.fromArray(1,3,5,7,8,6,4,2)
.max();

obs.subscribe( function (x) {
console.log(x);
});

=> 8

Optionally, a custom comparer can be applied to determine which is the maximum element.

function comparer (x, y) {
var xn = x.name, yn = y.name;
if (xn > yn) {
return 1;
} else if (xn < yn) {
return -1;
}
return 0;
}

var arr = { name: 'abc' }, { name: 'def' };
var obs = Rx.Observable
.fromArray(arr)
.max(comparer);

obs.subscribe( function (x) {
console.log(x);
});

=> 3

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="maxBy"></a>maxBy

Returns the elements in an observable sequence with the maximum key value.

!!! Syntax

obs.maxBy(keySelector, comparer)

!!! Parameters

* keySelector
> _Required_ **Function** - Key selector function.

* comparer
> _Optional_ **Function** - Comparer used to compare key values.

!!! Example

var arr = { count: 24 }, { count: 42 }
var obs = Rx.Observable
.fromArray(arr)
.maxBy( function (x) {
return x.count;
});

obs.subscribe( function (x) {
console.log(x);
});

=> { count: 42 }, { count: 24 }
function comparer (x, y) {
if (x > y) {
return 1;
} else if (x < y) {
return -1;
}
return 0;
}

var arr = { name: 'abc' }, { name: 'def' }
var obs = Rx.Observable
.fromArray(arr)
.maxBy(
function (x) {
return x.count;
},
comparer);

obs.subscribe( function (x) {
console.log(x);
});

=> { name: 'def' }, { name: 'abc' }

!!! Return Value

An observable sequence containing a list of zero or more elements that have a maximum key value.

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="merge2"></a>merge

!!! Syntax

obs.merge(maxConcurrent)
obs.merge(other)

!!! Parameters

!!! Return Value

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="mergeObservable"></a>mergeObservable

!!! Syntax

obs.mergeObservable()

!!! Parameters

!!! Return Value

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="min"></a>min

!!! Syntax

obs.min(comparer)

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="minBy"></a>minBy

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="multicast"></a>multicast

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.binding.js

NPM:

- rx module

NuGet:

- RxJS-Binding

!! <a id="observeOn"></a>observeOn

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="onErrorResumeNext2"></a>onErrorResumeNext

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="publish"></a>publish

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.binding.js

NPM:

- rx module

NuGet:

- RxJS-Binding

!! <a id="publishLast"></a>publishLast

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.binding.js

NPM:

- rx module

NuGet:

- RxJS-Binding

!! <a id="publishValue"></a>publishValue

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.binding.js

NPM:

- rx module

NuGet:

- RxJS-Binding

!! <a id="refCount"></a>refCount

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.binding.js

NPM:

- rx module

NuGet:

- RxJS-Binding

!! <a id="repeat2"></a>repeat

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="replay"></a>replay

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.binding.js

NPM:

- rx module

NuGet:

- RxJS-Binding

!! <a id="retry"></a>retry

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="sample"></a>sample

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="scan"></a>scan

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="select"></a>select

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="selectMany"></a>selectMany

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="single"></a>single

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="singleOrDefault"></a>singleOrDefault

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="skip"></a>skip

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="skipLast"></a>skipLast

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

!! <a id="skipUntil"></a>skipUntil

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="skipWhile"></a>skipWhile

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="startWith"></a>startWith

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="subscribe"></a>subscribe

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="subscribeOn"></a>subscribeOn

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="sum"></a>sum

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.aggregates.js

NPM:

- rx module

NuGet:

- RxJS-Aggregates

!! <a id="switchLatest"></a>switchLatest

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="take"></a>take

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="takeLast"></a>takeLast

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

!! <a id="takeLastBuffer"></a>takeLastBuffer

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

!! <a id="takeUntil"></a>takeUntil

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="takeWhile"></a>takeWhile

!!! Syntax

!!! Parameters

!!! Example

!!! Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

!! <a id="throwException"></a>throwException

Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.

!!! Syntax

Rx.Observable.throwException(exception, scheduler);

!!! Parameters

* exception
  
  > _Required_ **Any** - Error object used for the sequence's termination.

* scheduler

  > _Optional_ **Scheduler** - Scheduler to send the exceptional termination call. This parameter is typically used when creating a sequence of anonymously typed elements.

!!! Return Value

The observable sequence that terminates exceptionally with the specified exception object.

!!! Example

The follow example shows throwException in action where the observable collection throws an error, and the observer is notified by the onError handler.

var obs = Rx.Observable.throwException(new Error('Error!'));

var subscription = obs.subscribe(
function () { console.log('next'); },
function (e) { console.log(error.message); },
function () { console.log('done');
);

=> Error!
{code:javascript}

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="timeInterval"></a>timeInterval

Syntax

Parameters

Example

Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

<a id="timeout"></a>timeout

Syntax

Parameters

Example

Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

<a id="toArray"></a>toArray

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="using"></a>using

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="where"></a>where

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="window"></a>window

Syntax

Parameters

Example

Dependencies

Files:

- rx.js
- rx.coincidence.js

NPM:

- rx module

NuGet:

- RxJS-Coincidence

<a id="windowWithCount"></a>windowWithCount

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

<a id="windowWithTime"></a>windowWithTime

Syntax

Parameters

Example

Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

<a id="windowWithTimeOrCount"></a>windowWithTimeOrCount

Syntax

Parameters

Example

Dependencies

Files:

- rx.js
- rx.time.js

NPM:

- rx module

NuGet:

- RxJS-Time

<a id="zip"></a>zip

Syntax

Parameters

Example

Dependencies

Files:

- rx.js

NPM:

- rx module

NuGet:

- RxJS-Main

Last edited Nov 13, 2012 at 11:59 PM by bennage, version 1

Comments

No comments yet.