UNPKG

3.06 kBJavaScriptView Raw
1"use strict";
2
3require("core-js/modules/es.symbol.js");
4
5require("core-js/modules/es.symbol.description.js");
6
7require("core-js/modules/es.symbol.iterator.js");
8
9require("core-js/modules/es.array.iterator.js");
10
11require("core-js/modules/es.string.iterator.js");
12
13require("core-js/modules/web.dom-collections.iterator.js");
14
15require("core-js/modules/es.array.from.js");
16
17require("core-js/modules/es.array.slice.js");
18
19require("core-js/modules/es.function.name.js");
20
21require("core-js/modules/es.regexp.exec.js");
22
23Object.defineProperty(exports, "__esModule", {
24 value: true
25});
26exports.init = void 0;
27
28require("core-js/modules/es.array.concat.js");
29
30require("core-js/modules/es.array.filter.js");
31
32require("core-js/modules/es.object.to-string.js");
33
34require("core-js/modules/es.array.find.js");
35
36function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
37
38function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
39
40function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
41
42function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
43
44function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
45
46function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
47
48var init = function init(_ref) {
49 var store = _ref.store;
50 var api = {
51 addNotification: function addNotification(notification) {
52 // Get rid of it if already exists
53 api.clearNotification(notification.id);
54
55 var _store$getState = store.getState(),
56 notifications = _store$getState.notifications;
57
58 store.setState({
59 notifications: [].concat(_toConsumableArray(notifications), [notification])
60 });
61 },
62 clearNotification: function clearNotification(id) {
63 var _store$getState2 = store.getState(),
64 notifications = _store$getState2.notifications;
65
66 store.setState({
67 notifications: notifications.filter(function (n) {
68 return n.id !== id;
69 })
70 });
71 var notification = notifications.find(function (n) {
72 return n.id === id;
73 });
74
75 if (notification && notification.onClear) {
76 notification.onClear();
77 }
78 }
79 };
80 var state = {
81 notifications: []
82 };
83 return {
84 api: api,
85 state: state
86 };
87};
88
89exports.init = init;
\No newline at end of file