From 5ee1f8f8d9f69f3539d13e6dac994a8163ee1ecc Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Tue, 30 Jul 2019 17:19:23 +0200 Subject: [PATCH] Export the function itself --- packages/notification/src/index.js | 2 +- packages/notification/src/notification.js | 47 +++++++++---------- .../notification/src/vpu-notification-demo.js | 4 +- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/packages/notification/src/index.js b/packages/notification/src/index.js index 33206ad7..d1562574 100644 --- a/packages/notification/src/index.js +++ b/packages/notification/src/index.js @@ -1,4 +1,4 @@ import './vpu-notification'; -import send from './notification'; +import { send } from './notification'; export { send }; diff --git a/packages/notification/src/notification.js b/packages/notification/src/notification.js index a6a66394..ac18c030 100644 --- a/packages/notification/src/notification.js +++ b/packages/notification/src/notification.js @@ -1,26 +1,25 @@ +/** + * Sends a notification via the event + * + * example options: + * + * { + * "summary": "Item deleted", + * "body": "Item foo was deleted!", + * "type": "info", + * "timeout": 5, + * } + * + * @param options + */ +function send(options) { + const event = new CustomEvent("vpu-notification-send", { + bubbles: true, + cancelable: true, + detail: options, + }); -module.exports = { - /** - * Sends a notification via the event - * - * example options: - * - * { - * "summary": "Item deleted", - * "body": "Item foo was deleted!", - * "type": "info", - * "timeout": 5, - * } - * - * @param options - */ - send: (options) => { - const event = new CustomEvent("vpu-notification-send", { - bubbles: true, - cancelable: true, - detail: options, - }); + window.dispatchEvent(event); +} - window.dispatchEvent(event); - }, -}; +export { send }; diff --git a/packages/notification/src/vpu-notification-demo.js b/packages/notification/src/vpu-notification-demo.js index d2b595ac..dfece94b 100644 --- a/packages/notification/src/vpu-notification-demo.js +++ b/packages/notification/src/vpu-notification-demo.js @@ -1,5 +1,5 @@ import {i18n} from './i18n'; -import notification from './notification'; +import {send as notify} from './notification'; import {html, LitElement} from 'lit-element'; import './vpu-notification'; @@ -49,7 +49,7 @@ class NotificationDemo extends LitElement { send() { const types = ["primary", "link", "info", "success", "danger", "warning"]; - notification.send({ + notify({ "summary": "Item deleted", "body": `Item ${Math.random().toString(36).substring(7)} foo was deleted!`, "type": types[Math.floor(Math.random() * types.length)], -- GitLab