Skip to content

Latest commit

 

History

History
180 lines (108 loc) · 4.23 KB

File metadata and controls

180 lines (108 loc) · 4.23 KB

Rx.SerialDisposable class

Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource.

Usage

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

var serialDisposable = new Rx.SerialDisposable();

var d1 = Rx.Disposable.create(() => console.log('one'));

serialDisposable.setDisposable(d1);

var d2 = Rx.Disposable.create(() => console.log('two'));

serialDisposable.setDisposable(d2);
// => one

serialDisposable.dispose();
// = two

Location

  • rx.js

SerialDisposable Constructor

SerialDisposable Instance Methods

SerialDisposable Instance Properties

SerialDisposable Constructor

Rx.SerialDisposable()

#

Initializes a new instance of the Rx.SerialDisposable class.

Example

var serialDisposable = new Rx.SerialDisposable();

console.log(serialDisposable.isDisposed);
// => false

Location

  • rx.js

SerialDisposable Instance Methods

Rx.SerialDisposable.prototype.dispose()

#

Disposes the underlying disposable as well as all future replacements.

Example

var serialDisposable = new Rx.SerialDisposable();

var d1 = Rx.Disposable.create(() => console.log('one'));

serialDisposable.setDisposable(disposable);

serialDisposable.dispose();
// => one

var d2 = Rx.Disposable.create(() => console.log('two'));

// => two

Location

  • rx.js

Rx.SerialDisposable.prototype.getDisposable()

#

Gets the underlying disposable.

Returns

(Disposable): The underlying disposable.

Example

var serialDisposable = new Rx.SerialDisposable();

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

serialDisposable.setDisposable(disposable);

var d = serialDisposable.getDisposable();

console.log(d === disposable);

Location

  • rx.js

Rx.SerialDisposable.prototype.setDisposable(value)

#

Sets the underlying disposable.

Arguments

  1. value (Disposable): The new underlying disposable.

Example

var serialDisposable = new Rx.SerialDisposable();

var d1 = Rx.Disposable.create(() => console.log('one'));

serialDisposable.setDisposable(d1);

serialDisposable.dispose();
// => one

var d2 = Rx.Disposable.create(() => console.log('two'));

serialDisposable.setDisposable(d2);
// => two

Location

  • rx.js

SerialDisposable Instance Properties

isDisposed

#

Gets a value that indicates whether the object is disposed.

Example

var serialDisposable = new Rx.SerialDisposable();

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

serialDisposable.setDisposable(disposable);

console.log(serialDisposable.isDisposed);
// => false

serialDisposable.dispose();
// => disposed

console.log(serialDisposable.isDisposed);
// => true

Location

  • rx.js