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.
例
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.
例
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.
返回值
(Disposable): The underlying disposable.
例
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.
参数
value
(Disposable): The new underlying disposable.
例
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.
例
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