NotificationManager

Description

A notification manager used to create Notifications to be shown to the user.

An instance of this class is always available as the atom.notifications global.

API documentation

Events

::onDidAddNotification(callback)

Invoke the given callback after a notification has been added.

Argument Description
callback

Function to be called after the notification is added.

notification

The Notification that was added.

Return values
  • Returns a Disposable on which .dispose() can be called to unsubscribe.

::onDidClearNotifications(callback)

Invoke the given callback after the notifications have been cleared.

Argument Description
callback

Function to be called after the notifications are cleared.

Return values
  • Returns a Disposable on which .dispose() can be called to unsubscribe.

Adding Notifications

::addSuccess(message, options)

Add a success notification.

Argument Description
message

A String message

options optional

An options Object with the following keys:

buttons optional

An Array of Object where each Object has the following options:

className optional

String a class name to add to the button's default class name (btn btn-success).

onDidClick optional

Function callback to call when the button has been clicked. The context will be set to the NotificationElement instance.

text

String inner text for the button

description optional

A Markdown String containing a longer description about the notification. By default, this will not preserve newlines and whitespace when it is rendered.

detail optional

A plain-text String containing additional details about the notification. By default, this will preserve newlines and whitespace when it is rendered.

dismissable optional

A Boolean indicating whether this notification can be dismissed by the user. Defaults to false.

icon optional

A String name of an icon from Octicons to display in the notification header. Defaults to 'check'.

Return values

::addInfo(message, options)

Add an informational notification.

Argument Description
message

A String message

options optional

An options Object with the following keys:

buttons optional

An Array of Object where each Object has the following options:

className optional

String a class name to add to the button's default class name (btn btn-info).

onDidClick optional

Function callback to call when the button has been clicked. The context will be set to the NotificationElement instance.

text

String inner text for the button

description optional

A Markdown String containing a longer description about the notification. By default, this will not preserve newlines and whitespace when it is rendered.

detail optional

A plain-text String containing additional details about the notification. By default, this will preserve newlines and whitespace when it is rendered.

dismissable optional

A Boolean indicating whether this notification can be dismissed by the user. Defaults to false.

icon optional

A String name of an icon from Octicons to display in the notification header. Defaults to 'info'.

Return values

::addWarning(message, options)

Add a warning notification.

Argument Description
message

A String message

options optional

An options Object with the following keys:

buttons optional

An Array of Object where each Object has the following options:

className optional

String a class name to add to the button's default class name (btn btn-warning).

onDidClick optional

Function callback to call when the button has been clicked. The context will be set to the NotificationElement instance.

text

String inner text for the button

description optional

A Markdown String containing a longer description about the notification. By default, this will not preserve newlines and whitespace when it is rendered.

detail optional

A plain-text String containing additional details about the notification. By default, this will preserve newlines and whitespace when it is rendered.

dismissable optional

A Boolean indicating whether this notification can be dismissed by the user. Defaults to false.

icon optional

A String name of an icon from Octicons to display in the notification header. Defaults to 'alert'.

Return values

::addError(message, options)

Add an error notification.

Argument Description
message

A String message

options optional

An options Object with the following keys:

buttons optional

An Array of Object where each Object has the following options:

className optional

String a class name to add to the button's default class name (btn btn-error).

onDidClick optional

Function callback to call when the button has been clicked. The context will be set to the NotificationElement instance.

text

String inner text for the button

description optional

A Markdown String containing a longer description about the notification. By default, this will not preserve newlines and whitespace when it is rendered.

detail optional

A plain-text String containing additional details about the notification. By default, this will preserve newlines and whitespace when it is rendered.

dismissable optional

A Boolean indicating whether this notification can be dismissed by the user. Defaults to false.

icon optional

A String name of an icon from Octicons to display in the notification header. Defaults to 'flame'.

stack optional

A preformatted String with stack trace information describing the location of the error. Requires detail to be set.

Return values

::addFatalError(message, options)

Add a fatal error notification.

Argument Description
message

A String message

options optional

An options Object with the following keys:

buttons optional

An Array of Object where each Object has the following options:

className optional

String a class name to add to the button's default class name (btn btn-error).

onDidClick optional

Function callback to call when the button has been clicked. The context will be set to the NotificationElement instance.

text

String inner text for the button

description optional

A Markdown String containing a longer description about the notification. By default, this will not preserve newlines and whitespace when it is rendered.

detail optional

A plain-text String containing additional details about the notification. By default, this will preserve newlines and whitespace when it is rendered.

dismissable optional

A Boolean indicating whether this notification can be dismissed by the user. Defaults to false.

icon optional

A String name of an icon from Octicons to display in the notification header. Defaults to 'bug'.

stack optional

A preformatted String with stack trace information describing the location of the error. Requires detail to be set.

Return values

Getting Notifications

::getNotifications()

Get all the notifications.

Return values

Managing Notifications

::clear()

Clear all the notifications.