From 0e9dbb6e75babbc7c6ca4de2daf55d7e926f8aa3 Mon Sep 17 00:00:00 2001 From: Krolock Date: Mon, 7 Mar 2016 09:26:11 +0100 Subject: [PATCH 1/2] add callback parameter to process message in calling angular app --- src/growlFactory.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/growlFactory.js b/src/growlFactory.js index d3e5329..1afeba7 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -57,6 +57,16 @@ angular.module("angular-growl").provider("growl", function() { this.onlyUniqueMessages = function(onlyUniqueMessages) { _onlyUniqueMessages = onlyUniqueMessages; }; + + /** + * defines a callback that would be called with the message object as parameter + * this callback can be use to process the message in the angular app, e.g. write the message to a status bar + * + * @param {function} callback default: null + */ + this.registerCallback = function (callback) { + _callback = callback; + } /** * $http interceptor that can be added to array of $http interceptors during config phase of application @@ -112,6 +122,9 @@ angular.module("angular-growl").provider("growl", function() { }; broadcastMessage(message); + if (_callback) { + _callback(message); + } } /** From e11bdca75bd5f0bdd0cf5317247069aac6163ad4 Mon Sep 17 00:00:00 2001 From: Krolock Date: Mon, 7 Mar 2016 12:13:51 +0100 Subject: [PATCH 2/2] add semicolon and declare _callback variable --- src/growlFactory.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/growlFactory.js b/src/growlFactory.js index 1afeba7..ed6e64c 100644 --- a/src/growlFactory.js +++ b/src/growlFactory.js @@ -6,7 +6,8 @@ angular.module("angular-growl").provider("growl", function() { _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', - _onlyUniqueMessages = true; + _onlyUniqueMessages = true, + _callback = null; /** * set a global timeout (time to live) after which messages will be automatically closed @@ -66,7 +67,7 @@ angular.module("angular-growl").provider("growl", function() { */ this.registerCallback = function (callback) { _callback = callback; - } + }; /** * $http interceptor that can be added to array of $http interceptors during config phase of application