1 | import "core-js/modules/es.array.concat.js";
|
2 | import "core-js/modules/es.array.filter.js";
|
3 | import "core-js/modules/es.object.to-string.js";
|
4 | import "core-js/modules/es.array.find.js";
|
5 | import "core-js/modules/es.symbol.js";
|
6 | import "core-js/modules/es.symbol.description.js";
|
7 | import "core-js/modules/es.symbol.iterator.js";
|
8 | import "core-js/modules/es.array.iterator.js";
|
9 | import "core-js/modules/es.string.iterator.js";
|
10 | import "core-js/modules/web.dom-collections.iterator.js";
|
11 | import "core-js/modules/es.array.from.js";
|
12 | import "core-js/modules/es.array.slice.js";
|
13 | import "core-js/modules/es.function.name.js";
|
14 | import "core-js/modules/es.regexp.exec.js";
|
15 |
|
16 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
17 |
|
18 | function _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."); }
|
19 |
|
20 | function _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); }
|
21 |
|
22 | function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
23 |
|
24 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
25 |
|
26 | function _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; }
|
27 |
|
28 | export var init = function init(_ref) {
|
29 | var store = _ref.store;
|
30 | var api = {
|
31 | addNotification: function addNotification(notification) {
|
32 |
|
33 | api.clearNotification(notification.id);
|
34 |
|
35 | var _store$getState = store.getState(),
|
36 | notifications = _store$getState.notifications;
|
37 |
|
38 | store.setState({
|
39 | notifications: [].concat(_toConsumableArray(notifications), [notification])
|
40 | });
|
41 | },
|
42 | clearNotification: function clearNotification(id) {
|
43 | var _store$getState2 = store.getState(),
|
44 | notifications = _store$getState2.notifications;
|
45 |
|
46 | store.setState({
|
47 | notifications: notifications.filter(function (n) {
|
48 | return n.id !== id;
|
49 | })
|
50 | });
|
51 | var notification = notifications.find(function (n) {
|
52 | return n.id === id;
|
53 | });
|
54 |
|
55 | if (notification && notification.onClear) {
|
56 | notification.onClear();
|
57 | }
|
58 | }
|
59 | };
|
60 | var state = {
|
61 | notifications: []
|
62 | };
|
63 | return {
|
64 | api: api,
|
65 | state: state
|
66 | };
|
67 | }; |
\ | No newline at end of file |