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

Latest commit

 

History

History
105 lines (72 loc) · 2.37 KB

narydisposable.md

File metadata and controls

105 lines (72 loc) · 2.37 KB

NAryDisposable class

Represents an immutable group of disposable resources that are disposed together.

Usage

The follow example shows the basic usage of a NAryDisposable.

const d1 = Disposable.create(() => console.log('one'));
const d2 = Disposable.create(() => console.log('two'));
const d3 = Disposable.create(() => console.log('three'));

// Initialize with two disposables
const disposables = new NAryDisposable([d1, d2, d3]);

disposables.dispose();
// => one
// => two
// => three

NAryDisposable Constructor

NAryDisposable Instance Methods

NAryDisposable Instance Properties

NAryDisposable Constructor

NAryDisposable(disposables)

Creates a new group of disposable resources that are disposed together.

Arguments

  1. disposables: Array - Disposables that will be disposed together.

Example

const d1 = Disposable.create(() => console.log('one'));
const d2 = Disposable.create(() => console.log('two'));
const d3 = Disposable.create(() => console.log('three'));

// Initialize with two disposables
const disposables = new NAryDisposable([d1, d2, d3]);

disposables.dispose();
// => one
// => two
// => three

NAryDisposable Instance Methods

NAryDisposable.prototype.dispose()

Disposes the underlying disposables.

Example

const d1 = Disposable.create(() => console.log('one'));
const d2 = Disposable.create(() => console.log('two'));
const d3 = Disposable.create(() => console.log('three'));

// Initialize with two disposables
const disposables = new NAryDisposable([d1, d2, d3]);

disposables.dispose();
// => one
// => two
// => three

NAryDisposable 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 d3 = Disposable.create(() => console.log('three'));

const disposables = new NAryDisposable([d1, d2, d3]);

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

disposables.dispose();
// => disposed

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