Disposable

Description

A handle to a resource that can be disposed. For example, Emitter::on returns disposables representing subscriptions.

API documentation

Construction and Destruction

::constructor(disposalAction)

Construct a Disposable

Argument Description
disposalAction

A Function to call when Disposable::dispose is called for the first time.

::dispose()

Perform the disposal action, indicating that the resource associated with this disposable is no longer needed.

You can call this method more than once, but the disposal action will only be performed the first time.

Other methods

.isDisposable(object)

Ensure that object correctly implements the Disposable contract.

Argument Description
object

An Object you want to perform the check against.

Return values
  • Returns a Boolean indicating whether object is a valid Disposable.