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).
- amb
- catchException
- concat
- create
- createWithDisposable
- defer
- doWhile
- forIn
- forkJoin
- fromArray
- generate
- generateWithAbsoluteTime
- generateWithRelativeTime
- ifThen
- interval
- merge
- never
- onErrorResumeNext
- range
- repeat
- returnValue
- start
- switchCase
- timer
- toAsync
- when
- whileDo
- aggregate
- all
- amb
- and
- any
- asObservable
- average
- buffer
- bufferWithCount
- bufferWithTime
- bufferWithTimeOrCount
- catchException
- combineLatest
- concat
- contains
- count
- defaultIfEmpty
- delay
- dematerialize
- distinct
- distinctUntilChanged
- doAction
- doWhile
- elementAt
- elementAtOrDefault
- empty
- expand
- finallyAction
- first
- firstOrDefault
- forkJoin
- groupBy
- groupByUntil
- groupJoin
- ignoreElements
- isEmpty
- join
- last
- lastOrDefault
- manySelect
- max
- maxBy
- merge
- mergeObservable
- min
- minBy
- multicast
- observeOn
- onErrorResumeNext
- publish
- publishLast
- publishValue
- refCount
- repeat
- replay
- retry
- sample
- scan
- select
- selectMany
- single
- singleOrDefault
- skip
- skipLast
- skipUntil
- skipWhile
- startWith
- subscribe
- subscribeOn
- sum
- switchLatest
- take
- takeLast
- takeLastBuffer
- takeUntil
- takeWhile
- throttle
- throwException
- timeInterval
- timeout
- toArray
- using
- where
- window
- windowWithCount
- windowWithTime
- windowWithTimeOrCount
- zip
Propagates the observable sequence that reacts first.
array(Array|arguments): Observable sources competing to react first either as an array or arguments.
(Observable): An observable sequence that surfaces any of the given sequences, whichever reacted 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'Continues an observable sequence that is terminated by an exception with the next observable sequence.
array(Array|arguments): Observable sequences to catch exceptions for.
(Observable): An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
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);
});
// => 42Concatenates all of the specified observable sequences, as long as the previous observable sequence terminated successfully.
array(Array|arguments): Observable sequences to concatenate.
(Observable): An observable sequence that contains the elements of each given sequence, in sequential order.
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
// => 56Creates an observable sequence from a specified subscribe method implementation.
subscribe(Function): Implementation of the resulting observable sequence's subscribe method, optionally returning a function that will be wrapped in a disposable object.
(Observable): The observable sequence with the specified implementation for the subscribe method.
var source = Rx.Observable.create(function (observer) {
observer.onNext(42);
observer.onCompleted();
// Note that this is optional, you do not have to return this if you require no cleanup
return function () {
console.log('disposed');
};
});
var subscription = source.subscribe(function (x) {
console.log(x);
});
// => 42
subscription.dispose();
// => disposedCreates an observable sequence from a specified Subscribe method implementation.
subscribe(Function): Implementation of the resulting observable sequence's subscribe method.
(Observable): The observable sequence with the specified implementation for the subscribe method.
var source = Rx.Observable.createWithDisposable(function (observer) {
observer.onNext(42);
observer.onCompleted();
return Rx.Disposable.create(function () {
// Any cleanup that is required
console.log('disposed');
});
});
var subscription = source.subscribe(function (x) {
console.log(x);
});
// => 42
subscription.dispose();
// => disposedReturns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
observableFactory(Function): Observable factory function to invoke for each observer that subscribes to the resulting sequence.
(Observable): An observable sequence whose observers trigger an invocation of the given observable factory function.
var source = Rx.Observable.defer(function () {
return Rx.Observable.returnValue(42);
});
var subscription = source.subscribe(function (x) {
console.log(x);
});
// => 42