This is RxJS v 4. Find the latest version here
Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource.
The follow example shows the basic usage of an Rx.SerialDisposable.
var serialDisposable = new Rx.SerialDisposable();
var d1 = Rx.Disposable.create(function () {
console.log('one');
});
serialDisposable.setDisposable(d1);
var d2 = Rx.Disposable.create(function () {
console.log('two');
});
serialDisposable.setDisposable(d2);
// => one
serialDisposable.dispose();
// = two
- rx.js
Initializes a new instance of the Rx.SerialDisposable
class.
var serialDisposable = new Rx.SerialDisposable();
console.log(serialDisposable.isDisposed);
// => false
- rx.js
Disposes the underlying disposable as well as all future replacements.
var serialDisposable = new Rx.SerialDisposable();
var d1 = Rx.Disposable.create(function () {
console.log('one');
});
serialDisposable.setDisposable(disposable);
serialDisposable.dispose();
// => one
var d2 = Rx.Disposable.create(function () {
console.log('two');
});
// => two
- rx.js
Gets the underlying disposable.
(Disposable): The underlying disposable.
var serialDisposable = new Rx.SerialDisposable();
var disposable = Rx.Disposable.create(function () {
console.log('disposed');
});
serialDisposable.setDisposable(disposable);
var d = serialDisposable.getDisposable();
console.log(d === disposable);
- rx.js
Sets the underlying disposable.
value
(Disposable): The new underlying disposable.
var serialDisposable = new Rx.SerialDisposable();
var d1 = Rx.Disposable.create(function () {
console.log('one');
});
serialDisposable.setDisposable(d1);
serialDisposable.dispose();
// => one
var d2 = Rx.Disposable.create(function () {
console.log('two');
});
serialDisposable.setDisposable(d2);
// => two
- rx.js
Gets a value that indicates whether the object is disposed.
var serialDisposable = new Rx.SerialDisposable();
var disposable = Rx.Disposable.create(function () {
console.log('disposed');
});
serialDisposable.setDisposable(disposable);
console.log(serialDisposable.isDisposed);
// => false
serialDisposable.dispose();
// => disposed
console.log(serialDisposable.isDisposed);
// => true
- rx.js