Skip to content

Commit 8151dcd

Browse files
committed
Avoid usage of impure functions within reducers
fixes #2
1 parent ec41b03 commit 8151dcd

File tree

6 files changed

+7
-4
lines changed

6 files changed

+7
-4
lines changed

dist/react-notification-system-redux.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16631,6 +16631,7 @@ function show(opts) {
1663116631
return _extends({
1663216632
type: _const.RNS_SHOW_NOTIFICATION
1663316633
}, opts, {
16634+
uid: opts.uid || Date.now(),
1663416635
level: level
1663516636
});
1663616637
}
@@ -16787,7 +16788,7 @@ function Notifications(state, action) {
1678716788

1678816789
switch (action.type) {
1678916790
case _const.RNS_SHOW_NOTIFICATION:
16790-
return [].concat(_toConsumableArray(state), [_extends({}, (0, _lodash.omit)(action, 'type'), { uid: action.uid || Date.now() })]);
16791+
return [].concat(_toConsumableArray(state), [_extends({}, (0, _lodash.omit)(action, 'type'), { uid: action.uid })]);
1679116792
case _const.RNS_HIDE_NOTIFICATION:
1679216793
return (0, _lodash.filter)(state, function (notification) {
1679316794
return notification.uid !== action.uid;

dist/react-notification-system-redux.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function show(opts) {
3535
return _extends({
3636
type: _const.RNS_SHOW_NOTIFICATION
3737
}, opts, {
38+
uid: opts.uid || Date.now(),
3839
level: level
3940
});
4041
}

lib/reducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Notifications(state, action) {
1919

2020
switch (action.type) {
2121
case _const.RNS_SHOW_NOTIFICATION:
22-
return [].concat(_toConsumableArray(state), [_extends({}, (0, _lodash.omit)(action, 'type'), { uid: action.uid || Date.now() })]);
22+
return [].concat(_toConsumableArray(state), [_extends({}, (0, _lodash.omit)(action, 'type'), { uid: action.uid })]);
2323
case _const.RNS_HIDE_NOTIFICATION:
2424
return (0, _lodash.filter)(state, function (notification) {
2525
return notification.uid !== action.uid;

src/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export function show(opts, level = 'success') {
1818
return {
1919
type: RNS_SHOW_NOTIFICATION,
2020
...opts,
21+
uid: opts.uid || Date.now(),
2122
level
2223
};
2324
}

src/reducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function Notifications(state = [], action) {
77
case RNS_SHOW_NOTIFICATION:
88
return [
99
...state,
10-
{ ...omit(action, 'type'), uid: action.uid || Date.now() }
10+
{ ...omit(action, 'type'), uid: action.uid}
1111
];
1212
case RNS_HIDE_NOTIFICATION:
1313
return filter(state, notification => {

0 commit comments

Comments
 (0)