From ff7077383a2a599318e55521d36fbd50c3b49024 Mon Sep 17 00:00:00 2001 From: chikeozulumba Date: Fri, 9 Oct 2020 08:52:59 +0100 Subject: [PATCH] Add an optional callback function to the 'alert' function. --- src/notie.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/notie.js b/src/notie.js index 03d1d27..6aaf974 100644 --- a/src/notie.js +++ b/src/notie.js @@ -176,7 +176,8 @@ export const alert = ({ text, time = options.alertTime, stay = false, - position = options.positions.alert || position.top + position = options.positions.alert || position.top, + callback }) => { blur() hideAlerts() @@ -198,7 +199,7 @@ export const alert = ({ addToDocument(element, position) if (time && time < 1) time = 1 - if (!stay && time) wait(time).then(() => removeFromDocument(id, position)) + if (!stay && time) wait(time).then(() => removeFromDocument(id, position)).then(() => typeof callback === 'function' && callback()) } export const force = ({