From 523ca698ea94ff44708aefd19a4aadd4e87539ec Mon Sep 17 00:00:00 2001 From: Jonne Date: Mon, 9 Dec 2019 16:55:35 +0200 Subject: [PATCH] Return reference to created notification With the reference you can access to notification after it has been dispatched. For example if you want to close the notification via other method than direct interaction with the notification, having reference is a must. --- dist/vue-notifications.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/vue-notifications.js b/dist/vue-notifications.js index f49c508..9d4b3e1 100644 --- a/dist/vue-notifications.js +++ b/dist/vue-notifications.js @@ -50,9 +50,11 @@ function showMessage(config, vueApp) { const valuesObj = getValues(config, vueApp); const isMethodOverridden = VueNotifications.pluginOptions[valuesObj.type]; const method = isMethodOverridden ? VueNotifications.pluginOptions[valuesObj.type] : console.log; - method(valuesObj, vueApp); + const reference = method(valuesObj, vueApp); if (config.cb) config.cb(); + + return reference; } function setMethod(vueApp, name, componentOptions) { let { methods } = componentOptions; @@ -75,7 +77,7 @@ function makeMethod(vueApp, methodName, componentOptions) { ...methodConfig, ...config }; - showMessage(newConfig, vueApp); + return showMessage(newConfig, vueApp); }; } function initVueNotificationPlugin(vueApp, notifications) {