Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ExtensionContext

The extension context is passed to the extension's activate function and contains utilities for the extension lifecycle.

since

Sourcegraph 3.0. Use export function activate(ctx?: ExtensionContext) { ... } for prior versions (to ensure your code handles the pre-3.0-preview case when ctx is undefined).

Hierarchy

  • ExtensionContext

Index

Properties

Properties

subscriptions

subscriptions: { add: (unsubscribable: Unsubscribable | (() => void)) => void }

An object that maintains subscriptions to resources that should be freed when the extension is deactivated.

When an extension is deactivated, first its exported deactivate function is called (if one exists). The deactivate function may be async, in which case deactivation blocks on it finishing. Next, regardless of whether the deactivate function finished successfully or rejected with an error, all unsubscribables passed to {@link ExtensionContext#subscriptions#add} are unsubscribed from.

(An extension is deactivated when the user disables it, or after an arbitrary time period if its activationEvents no longer evaluate to true.)

Type declaration

  • add: (unsubscribable: Unsubscribable | (() => void)) => void

    Mark a resource's teardown function to be called when the extension is deactivated.

    param

    An Unsubscribable that frees (unsubscribes from) a resource, or a plain function that does the same. Async functions are not supported. (If deactivation requires async operations, make the deactivate function async; that is supported.)

Generated using TypeDoc