> For the complete documentation index, see [llms.txt](https://soufatn.gitbook.io/rxjs-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://soufatn.gitbook.io/rxjs-book/summary/testing/subscription.md).

# Rx.Subscription

Records information about subscriptions to and unsubscriptions from observable sequences.

### Location

* rx.testing.js

## `Subscription Constructor` #\#

* [`constructor`](/rxjs-book/summary/testing/subscription.md#rxsubscriptionsubscribe-unsubscribe)

## `Subscription Instance Methods` #\#

* [`equals`](/rxjs-book/summary/testing/subscription.md#rxsubscriptionprototypeequalsother)
* [`toString`](/rxjs-book/summary/testing/subscription.md#rxsubscriptionprototypetostring)

## `Subscription Instance Properties` #\#

* [`subscribe`](/rxjs-book/summary/testing/subscription.md#subscribe)
* [`unsubscribe`](/rxjs-book/summary/testing/subscription.md#unsubscribe)

## *Subscription Constructor* #\#

### `Rx.Subscription(subscribe, unsubscribe)` <a href="#rxsubscriptionsubscribe-unsubscribe" id="rxsubscriptionsubscribe-unsubscribe"></a>

[#](/rxjs-book/summary/testing/subscription.md#rxsubscriptionsubscribe-unsubscribe) [Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/testing/subscription.js#L8-L11)

Creates a new subscription object with the given virtual subscription and unsubscription time.

#### Arguments

1. `subscribe` *(Number)*: Virtual time at which the subscription occurred.
2. `[unsubscribe = Number.MAX_VALUE]` *(Number)*: Virtual time at which the unsubscription occurred.

#### Example

```javascript
var subscription = new Rx.Subscription(200, 1000);

console.log(recorded.time);
// => 200

console.log(recorded.unsubscribe);
// => 1000
```

### Location

* rx.testing.js

## *Subscription Instance Methods* #\#

### `Rx.Subscription.prototype.equals(other)` <a href="#rxsubscriptionprototypeequalsother" id="rxsubscriptionprototypeequalsother"></a>

[#](/rxjs-book/summary/testing/subscription.md#rxsubscriptionprototypeequalsother) [Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/testing/subscription.js#L18-L20)

Checks whether the given subscription is equal to the current instance.

#### Arguments

1. `other` *(Subscription)*: Subscription object to check for equality.

#### Returns

*(Boolean)*: Returns `true` if the Subscription equals the other, else `false`.

#### Example

```javascript
var s1 = new Subscription(201, 500);
var s2 = new Subscription(201);
var s3 = new Subscription(201, 500);

console.log(s1.equals(s2));
// => false

console.log(s1.equals(s3));
// => true
```

### Location

* rx.testing.js

### `Rx.Subscription.prototype.toString()` <a href="#rxsubscriptionprototypetostring" id="rxsubscriptionprototypetostring"></a>

[#](/rxjs-book/summary/testing/subscription.md#rxsubscriptionprototypeequalsother) [Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/testing/subscription.js#L30-L32)

Returns a string representation of the current Subscription value.

#### Returns

*(String)*: String representation of the current Subscription value.

#### Example

```javascript
var s1 = new Subscription(201);

console.log(s1.toString());
// => (201, Infinite)

var s2 = new Subscription(201, 1000);
console.log(s2.toString());
// => (201, 1000)
```

### Location

* rx.testing.js

## *Subscription Instance Properties* #\#

### `subscribe` <a href="#subscribe" id="subscribe"></a>

[#](/rxjs-book/summary/testing/subscription.md#subscribe) [Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/testing/subscription.js#L8)

Gets the subscription virtual time.

#### Returns

*(Number)*: The subscription virtual time.

#### Example

```javascript
var s1 = new Subscription(201);

console.log(s1.subscribe);
// => 201
```

### Location

* rx.testing.js

### `unsubscribe` <a href="#unsubscribe" id="unsubscribe"></a>

[#](/rxjs-book/summary/testing/subscription.md#value) [Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/testing/subscription.js#L9)

Gets the unsubscription virtual time.

#### Returns

*(Number)*: The unsubscription virtual time.

#### Example

```javascript
var s1 = new Subscription(201, 500);

console.log(r1.unsubscribe);
// => foo
```

### Location

* rx.testing.js
