BinaryDisposable class
January 5, 2016 ยท View on GitHub
Represents an immutable group of two disposable resources that are disposed together.
Usage
The follow example shows the basic usage of a BinaryDisposable.
const d1 = Disposable.create(() => console.log('one'));
const d2 = Disposable.create(() => console.log('two'));
// Initialize with two disposables
const disposables = new BinaryDisposable(d1, d2);
disposables.dispose();
// => one
// => two
BinaryDisposable Constructor
BinaryDisposable Instance Methods
BinaryDisposable Instance Properties
BinaryDisposable Constructor
BinaryDisposable(first, second)
Creates a new group of two disposable resources that are disposed together.
Arguments
first:Disposable- The first disposable resource to add to the group.second:Disposable- The second disposable resource to add to the group.
Example
const d1 = Disposable.create(() => console.log('one'));
const d2 = Disposable.create(() => console.log('two'));
// Initialize with two disposables
const disposables = new BinaryDisposable(d1, d2);
disposables.dispose();
// => one
// => two
BinaryDisposable Instance Methods
BinaryDisposable.prototype.dispose()
Disposes the underlying disposables.
Example
const d1 = Disposable.create(() => console.log('one'));
const d2 = Disposable.create(() => console.log('two'));
const disposables = new BinaryDisposable(d1, d2);
disposables.dispose();
// => one
// => two
console.log(disposables.length);
// => 0
BinaryDisposable Instance Properties
isDisposed
Gets a value that indicates whether the object is disposed.
Example
const d1 = Disposable.create(() => console.log('one'));
const d2 = Disposable.create(() => console.log('two'));
const disposables = new BinaryDisposable(d1, d2);
console.log(disposables.isDisposed);
// => false
disposables.dispose();
// => disposed
console.log(disposables.isDisposed);
// => true