Valid message, options, and detail

This commit is contained in:
Kevin Sawicki
2015-07-07 12:16:29 -07:00
parent 24a56e974b
commit 4ba552c515

View File

@@ -9,6 +9,17 @@ class Notification
@dismissed = true
@dismissed = false if @isDismissable()
@displayed = false
@validate()
validate: ->
if typeof @message isnt 'string'
throw new Error("Notification must be created with string message: #{@message}")
if typeof @options isnt 'object'
throw new Error("Notification must be created with an options object: #{@options}")
if @options?.detail? and typeof @options.details isnt 'string'
throw new Error("Notification must be created with string detail: #{@options.detail}")
onDidDismiss: (callback) ->
@emitter.on 'did-dismiss', callback