UNPKG

1.46 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?: Array<{
31 className?: string | undefined;
32 onDidClick?(event: MouseEvent): void;
33 text?: string | undefined;
34 }> | undefined;
35 description?: string | undefined;
36 detail?: string | undefined;
37 dismissable?: boolean | undefined;
38 icon?: string | undefined;
39}
40
41export interface ErrorNotificationOptions extends NotificationOptions {
42 stack?: string | undefined;
43}