# Notification

Source: https://developers.inkdrop.app/modules/notification

Represents an in-app notification.
Notifications are rendered in the bottom right of the Application using the [Notification Manager](https://developers.inkdrop.app/modules/notification-manager).

---

## Properties

- **message** (string)

  Message of the notification.
- **type** ('success' | 'info' | 'warning' | 'error' | 'fatal')

  Type of the notification.

---

## Event Subscription: Dissmissed `onDidDismiss(callback)`

Invoke the given callback when the notification is dismissed.

### Parameters

- **callback** (() => void)

  A function which is called when the notification is dismissed.

### Returns

Returns a [Disposable][disposable] on which `.dispose()` can be called to unsubscribe.

```js
// Prepare: Create the notification
const notification = env.notifications.addInfo('Hello world!')

// Subscribe to the event
notification.onDidDismiss(() => {
  console.log('Notification dismissed')
})
```

---

## Event Subscription: Displayed `onDidDisplay(callback)`

Invoke the given callback when the notification is displayed.

### Parameters

- **callback** (() => void)

  A function which is called when the notification is displayed.

### Returns

Returns a [Disposable][disposable] on which `.dispose()` can be called to unsubscribe.

```js
// Prepare: Create the notification
const notification = env.notifications.addInfo('Hello world!')

// Subscribe to the event
notification.onDidDisplay(() => {
  console.log('Notification displayed')
})
```

---

## getType `getType()`

Gets the type of the notification.

### Parameters

No parameters

### Returns

Returns the type of the notification. (e.g. `'success'`)

```js
// Prepare: Create the notification
const notification = env.notifications.addInfo('Hello world!')

// Get the type
notification.getType()
```

---

## getMessage `getMessage()`

Gets the message of the notification.

### Parameters

No parameters

### Returns

Returns the message of the notification.

```js
// Prepare: Create the notification
const notification = env.notifications.addInfo('Hello world!')

// Get the message
notification.getMessage()
```

---

## dismiss `dismiss()`

Dismisses the notification, removing it from the UI. Calling this programmatically will call all callbacks added via `onDidDismiss`.

### Parameters

No parameters

### Returns

No return value.

```js
// Prepare: Create the notification
const notification = env.notifications.addInfo('Hello world!')

// Dismiss the notification
notification.dismiss()
```

[disposable]: https://developers.inkdrop.app/event-subscription/disposable
