Skip to main content
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
a month ago (0.1.0)
class AbortOnDispose
implements Disposable

An abstract superclass to bridge the gap between the internal AbortController and the external Disposable interface.

Examples

If you don't use TypeScript with version 5.2 or higher, use this class to free resources manually.

 const bar: AbortOnDispose = foo()
 try {
  // do something
 } finally {
  foo.cancel()
 }

If you use TypeScript with version 5.2 or higher, use the using keyword to have your item automatically disposed of.

 using bar: AbortOnDispose = foo()

 // do something
 // bar is automatically disposed of here (at the end of the block)

Constructors

new
AbortOnDispose(abortController: AbortController)

Properties

Methods

cancel(): void

Cancel the underlying subscription. Use this to free resources if you don't use TypeScript with version 5.2 or higher. (Otherwise, use the using keyword to have your item automatically disposed of.)

Add Package

deno add jsr:@hyveos/sdk

Import symbol

import { AbortOnDispose } from "@hyveos/sdk";

---- OR ----

Import directly with a jsr specifier

import { AbortOnDispose } from "jsr:@hyveos/sdk";

Add Package

npx jsr add @hyveos/sdk

Import symbol

import { AbortOnDispose } from "@hyveos/sdk";

Add Package

yarn dlx jsr add @hyveos/sdk

Import symbol

import { AbortOnDispose } from "@hyveos/sdk";

Add Package

pnpm dlx jsr add @hyveos/sdk

Import symbol

import { AbortOnDispose } from "@hyveos/sdk";

Add Package

bunx jsr add @hyveos/sdk

Import symbol

import { AbortOnDispose } from "@hyveos/sdk";