# Rx.Disposable

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`.

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

disposable.dispose();
// => disposed
```

### Location

* rx.js

## `Disposable Class Methods` #\#

* [`create`](#rxdisposablecreateaction)

## `Disposable Class Properties` #\#

* [`empty`](#rxdisposableempty)

## `Disposable Instance Methods` #\#

* [`dispose`](#rxdisposableprototypedispose)

## _Class Methods_ #\#

### `Rx.Disposable.create(action)` <a href="#rxdisposablecreateaction" id="rxdisposablecreateaction"></a>

[#](#rxdisposablecreateaction) [Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/disposables/disposable.js#L25)

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

#### Arguments

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

#### Returns

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

#### Example

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

disposable.dispose();
// => disposed
```

### Location

* rx.js

## _Disposable Class Properties_ #\#

### `Rx.Disposable.empty` <a href="#rxdisposableempty" id="rxdisposableempty"></a>

[#](#rxdisposableempty) [Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/disposables/disposable.js#L130)

Gets the disposable that does nothing when disposed.

#### Returns

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

#### Example

```javascript
var disposable = Rx.Disposable.empty;

disposable.dispose(); // Does nothing
```

### Location

* rx.js

## _Disposable Instance Methods_ #\#

### `Rx.Disposable.prototype.dispose()` <a href="#rxdisposableprototypedispose" id="rxdisposableprototypedispose"></a>

[#](#rxdisposableprototypedispose) [Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/disposables/disposable.js#L13-L18)

Performs the task of cleaning up resources.

#### Example

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

disposable.dispose();
// => disposed
```

### Location

* rx.js
