Rx.Disposable class

Provides a set of static methods for creating Disposables, which defines a method to release allocated resources.

Usage

The follow example shows the basic usage of an Rx.Disposable.

var disposable = Rx.Disposable.create(() => console.log('disposed'));

disposable.dispose();
// => disposed

Location

  • rx.js

Disposable Class Methods

Disposable Class Properties

Disposable Instance Methods

Class Methods

Rx.Disposable.create(action)

#

Creates a disposable object that invokes the specified action when disposed.

参数

  1. action (Function): Function to run during the first call to dispose. The action is guaranteed to be run at most once.

返回值

(Disposable): The disposable object that runs the given action upon disposal.

var disposable = Rx.Disposable.create(() => console.log('disposed'));

disposable.dispose();
// => disposed

Location

  • rx.js

Disposable Class Properties

Rx.Disposable.empty

#

Gets the disposable that does nothing when disposed.

返回值

(Disposable): The disposable that does nothing when disposed.

var disposable = Rx.Disposable.empty;

disposable.dispose(); // Does nothing

Location

  • rx.js

Disposable Instance Methods

Rx.Disposable.prototype.dispose()

#

Performs the task of cleaning up resources.

var disposable = Rx.Disposable.create(() => console.log('disposed'));

disposable.dispose();
// => disposed

Location

  • rx.js