Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Latest commit

 

History

History
101 lines (67 loc) · 2.22 KB

binarydisposable.md

File metadata and controls

101 lines (67 loc) · 2.22 KB

BinaryDisposable class

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

  1. first: Disposable - The first disposable resource to add to the group.
  2. 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