Skip to main content

Interface: Event()<T>

Interface to subscribe specific events.

Example

This is an example for an hypothetic function onDidValueChange implementing the Event interface.

import * as api from '@podman-desktop/api';

class MyValueManager {
private value: boolean | undefined = undefined;

private onChange(e: boolean) {
this.value = e;
console.log(this.value);
}

public init(subscriptions: api.Disposable[]) {
onDidValueChange(this.onChange, this, subscriptions);
}
}

export async function activate(extensionContext: api.ExtensionContext): Promise<void> {
const myValueManager = new MyValueManager();
myValueManager.init(extensionContext.subscriptions);
}

Type Parameters

T

Event(listener, thisArgs?, disposables?): Disposable

Interface to subscribe specific events.

Parameters

listener

(e) => any

The listener function will be called when the event happens.

thisArgs?

any

The this-argument which will be used when calling the event listener.

disposables?

Disposable[]

An array to which the resulting Disposable will be added.

Returns

Disposable

A disposable which unsubscribes the event listener.

Example

This is an example for an hypothetic function onDidValueChange implementing the Event interface.

import * as api from '@podman-desktop/api';

class MyValueManager {
private value: boolean | undefined = undefined;

private onChange(e: boolean) {
this.value = e;
console.log(this.value);
}

public init(subscriptions: api.Disposable[]) {
onDidValueChange(this.onChange, this, subscriptions);
}
}

export async function activate(extensionContext: api.ExtensionContext): Promise<void> {
const myValueManager = new MyValueManager();
myValueManager.init(extensionContext.subscriptions);
}

Defined in

packages/extension-api/src/extension-api.d.ts:157