Home Manual Reference Source Test Repository
import {Subscriber} from '@reactivex/rxjs/es6/Subscriber.js'
public class | source

Subscriber

Extends:

Subscription → Subscriber

Direct Subclass:

es6/observable/ConnectableObservable.js~RefCountSubscriber, es6/operators/refCount.js~RefCountSubscriber, es6/operators/sequenceEqual.js~SequenceEqualCompareToSubscriber, SubjectSubscriber

Indirect Subclass:

es6/observable/ConnectableObservable.js~ConnectableSubscriber

Implements the Observer interface and extends the Subscription class. While the Observer is the public API for consuming the values of an Observable, all Observers get converted to a Subscriber, in order to provide Subscription-like capabilities such as unsubscribe. Subscriber is a common type in RxJS, and crucial for implementing operators, but it is rarely used as a public API.

Test:

Static Method Summary

Static Public Methods
public static

create(next: function(x: ?T): void, error: function(e: ?any): void, complete: function(): void): Subscriber<T>

A static factory for a Subscriber, given a (potentially partial) definition of an Observer.

Constructor Summary

Public Constructor
public

constructor(destinationOrNext: Observer | function(value: T): void, error: function(e: ?any): void, complete: function(): void)

Method Summary

Public Methods
public

complete(): void

The Observer callback to receive a valueless notification of type complete from the Observable.

public

error(err: any): void

The Observer callback to receive notifications of type error from the Observable, with an attached Error.

public

next(value: T): void

The Observer callback to receive notifications of type next from the Observable, with a value.

Inherited Summary

From class Subscription
public

A flag to indicate whether this Subscription has already been unsubscribed.

public

Adds a tear down to be called during the unsubscribe() of this Subscription.

public

remove(subscription: Subscription): void

Removes a Subscription from the internal list of subscriptions that will unsubscribe during the unsubscribe process of this Subscription.

public

unsubscribe(): void

Disposes the resources held by the subscription.

Static Public Methods

public static create(next: function(x: ?T): void, error: function(e: ?any): void, complete: function(): void): Subscriber<T> source

A static factory for a Subscriber, given a (potentially partial) definition of an Observer.

Params:

NameTypeAttributeDescription
next function(x: ?T): void
  • optional

The next callback of an Observer.

error function(e: ?any): void
  • optional

The error callback of an Observer.

complete function(): void
  • optional

The complete callback of an Observer.

Return:

Subscriber<T>

A Subscriber wrapping the (partially defined) Observer represented by the given arguments.

Public Constructors

public constructor(destinationOrNext: Observer | function(value: T): void, error: function(e: ?any): void, complete: function(): void) source

Override:

Subscription#constructor

Params:

NameTypeAttributeDescription
destinationOrNext Observer | function(value: T): void
  • optional

A partially defined Observer or a next callback function.

error function(e: ?any): void
  • optional

The error callback of an Observer.

complete function(): void
  • optional

The complete callback of an Observer.

Public Methods

public complete(): void source

The Observer callback to receive a valueless notification of type complete from the Observable. Notifies the Observer that the Observable has finished sending push-based notifications.

Return:

void

public error(err: any): void source

The Observer callback to receive notifications of type error from the Observable, with an attached Error. Notifies the Observer that the Observable has experienced an error condition.

Params:

NameTypeAttributeDescription
err any
  • optional

The error exception.

Return:

void

public next(value: T): void source

The Observer callback to receive notifications of type next from the Observable, with a value. The Observable may call this method 0 or more times.

Params:

NameTypeAttributeDescription
value T
  • optional

The next value.

Return:

void