Skip to content

Disposables

Although most of the VSCode APIs are covered by reactive-vscode, sometimes you still need to work with Disposable, which is also described in VSCode API Patterns.

useDisposable accepts a disposable object and automatically disposes it when the current effect scope is disposed (e.g When the extension is deactivated, if useDisposable is called in the extension's setup function). useDisposable returns the disposable object itself as is.
ts
import type { TextDocument } from 'vscode'
import { 
defineExtension
,
useDisposable
} from 'reactive-vscode'
import { languages } from 'vscode' export =
defineExtension
(() => {
useDisposable
(languages.
registerFoldingRangeProvider
(
{
language
: 'markdown' },
{
provideFoldingRanges
(
document
: TextDocument) {
return [] }, }, )) })

Note that you don't need to use useDisposable for disposables created by any reactive-vscode functions. They are automatically disposed when the current effect scope is disposed.