This service can be injected in the following way:

import Route from '@ember/routing/route';
import {inject as service} from '@ember/service';

export default Route.extend({
    notifications: service(), // notifications will be available as a property

    // ... your other code
});

Then described below are the various methods that you are able to call from the Notifications Service once it is injected.

Show:
closeAllNotifications
(
  • outlet
)

Close all notifications for a particular outlet.

Parameters:

  • outlet String

    outlet to close notifications in

closeNotification
(
  • message
)

Close a notification given by a particular object.

Parameters:

  • message Object

    notification object

handleNotification
(
  • message
)
private

Internal method that handles a raw notification. This is used by all of the show____ methods, so most of the time it is best just to use the proper function to build the notification for you.

Parameters:

  • message Object

    options for the notification

showError
(
  • message
  • outlet
  • dismissable
)

Shows an error message, ie it shows a message to the selected outlet with the "error" styling.

Parameters:

  • message String

    Message to show in the notification.

  • outlet String

    Which outlet to render the notification into

  • dismissable Boolean | String

    If boolean, whether or not the notification will disappear on its own. If string, length of time before it disappears.

showInfo
(
  • message
  • outlet
  • dismissable
)

Shows an informational message, ie it shows a message to the selected outlet with the "info" styling.

Parameters:

  • message String

    Message to show in the notification.

  • outlet String

    Which outlet to render the notification into

  • dismissable Boolean | String

    If boolean, whether or not the notification will disappear on its own. If string, length of time before it disappears.

showSuccess
(
  • message
  • outlet
  • dismissable
)

Shows a success message

Parameters:

  • message String

    Message to show in the notification.

  • outlet String

    Which outlet to render the notification into

  • dismissable Boolean | String

    If boolean, whether or not the notification will disappear on its own. If string, length of time before it disappears.

showWarning
(
  • message
  • outlet
  • dismissable
)

Shows a warning message, ie it shows a message to the selected outlet with the "warning" styling.

Parameters:

  • message String

    Message to show in the notification.

  • outlet String

    Which outlet to render the notification into

  • dismissable Boolean | String

    If boolean, whether or not the notification will disappear on its own. If string, length of time before it disappears.

content

Array private

All of the notifications currently in the DOM. Internal only.