From 1cd5bb0f8d7a63642025cf383ffcafbb8e9ec44b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 22 Apr 2015 09:38:15 -0700 Subject: [PATCH] Mark NotificationManager public and add docs --- src/notification-manager.coffee | 35 +++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/notification-manager.coffee b/src/notification-manager.coffee index f811a501f..b1f71fe68 100644 --- a/src/notification-manager.coffee +++ b/src/notification-manager.coffee @@ -1,8 +1,8 @@ {Emitter, Disposable} = require 'event-kit' Notification = require '../src/notification' -# Experimental: Allows messaging the user. This will likely change, dont use -# quite yet! +# Public: A notification manager used to create {Notification}s to be shown +# to the user. module.exports = class NotificationManager constructor: -> @@ -13,6 +13,12 @@ class NotificationManager Section: Events ### + # Public: Invoke the given callback after a notification has been added. + # + # * `callback` {Function} to be called after the notification is added. + # * `notification` The {Notification} that was added. + # + # Returns a {Disposable} on which `.dispose()` can be called to unsubscribe. onDidAddNotification: (callback) -> @emitter.on 'did-add-notification', callback @@ -20,18 +26,43 @@ class NotificationManager Section: Adding Notifications ### + # Public: Add a success notification. + # + # * `message` A {String} message + # * `options` An options {Object} with optional keys such as: + # * `detail` A {String} with additional details about the notification addSuccess: (message, options) -> @addNotification(new Notification('success', message, options)) + # Public: Add an informational notification. + # + # * `message` A {String} message + # * `options` An options {Object} with optional keys such as: + # * `detail` A {String} with additional details about the notification addInfo: (message, options) -> @addNotification(new Notification('info', message, options)) + # Public: Add a warning notification. + # + # * `message` A {String} message + # * `options` An options {Object} with optional keys such as: + # * `detail` A {String} with additional details about the notification addWarning: (message, options) -> @addNotification(new Notification('warning', message, options)) + # Public: Add an error notification. + # + # * `message` A {String} message + # * `options` An options {Object} with optional keys such as: + # * `detail` A {String} with additional details about the notification addError: (message, options) -> @addNotification(new Notification('error', message, options)) + # Public: Add a fatal error notification. + # + # * `message` A {String} message + # * `options` An options {Object} with optional keys such as: + # * `detail` A {String} with additional details about the notification addFatalError: (message, options) -> @addNotification(new Notification('fatal', message, options))