UNPKG

1.49 kBTypeScriptView Raw
1import { Disposable } from "../index";
2
3/** A notification to the user containing a message and type. */
4export class Notification {
5 constructor(type: "warning" | "info" | "success", message: string, options?: NotificationOptions);
6 constructor(type: "fatal" | "error", message: string, options?: ErrorNotificationOptions);
7
8 // Event Subscription
9 /** Invoke the given callback when the notification is dismissed. */
10 onDidDismiss(callback: (notification: Notification) => void): Disposable;
11
12 /** Invoke the given callback when the notification is displayed. */
13 onDidDisplay(callback: (notification: Notification) => void): Disposable;
14
15 // Methods
16 /** Returns the Notification's type. */
17 getType(): string;
18
19 /** Returns the Notification's message. */
20 getMessage(): string;
21
22 /**
23 * Dismisses the notification, removing it from the UI. Calling this
24 * programmatically will call all callbacks added via onDidDismiss.
25 */
26 dismiss(): void;
27}
28
29export interface NotificationOptions {
30 buttons?:
31 | Array<{
32 className?: string | undefined;
33 onDidClick?(event: MouseEvent): void;
34 text?: string | undefined;
35 }>
36 | undefined;
37 description?: string | undefined;
38 detail?: string | undefined;
39 dismissable?: boolean | undefined;
40 icon?: string | undefined;
41}
42
43export interface ErrorNotificationOptions extends NotificationOptions {
44 stack?: string | undefined;
45}