Skip to content

Commit 35b6f12

Browse files
committed
Remove superfluous eventListener
1 parent bb8c4c6 commit 35b6f12

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

dist/middleware.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ var createWorker = function createWorker(worker, type) {
2222

2323
worker.addEventListener('message', function (_ref) {
2424
var data = _ref.data;
25-
26-
scopedDispatch(data);
27-
});
25+
return scopedDispatch(data);
26+
}, false);
2827

2928
return function (_ref2) {
3029
var dispatch = _ref2.dispatch,
@@ -37,10 +36,6 @@ var createWorker = function createWorker(worker, type) {
3736
var meta = action.meta;
3837

3938
if (meta && meta.webworker && meta.type === type) {
40-
worker.addEventListener('message', function (_ref3) {
41-
var data = _ref3.data;
42-
return dispatch(data);
43-
}, false);
4439
worker.postMessage(actionHelper(action, getState));
4540
}
4641
return next(action);

src/middleware.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import errorCheck from './error_check';
33

44
const createWorker = (worker, type, actionHelper=_.identity) => {
55
let scopedDispatch = _.noop;
6-
7-
worker.addEventListener('message', ({ data }) => {
8-
scopedDispatch(data);
9-
});
6+
7+
worker.addEventListener('message', ({ data }) => scopedDispatch(data), false);
108

119
return ({dispatch, getState}) => {
1210
scopedDispatch = dispatch;
@@ -15,7 +13,6 @@ const createWorker = (worker, type, actionHelper=_.identity) => {
1513
return (action) => {
1614
const {meta} = action;
1715
if (meta && meta.webworker && meta.type === type) {
18-
worker.addEventListener('message', ({data}) => dispatch(data), false);
1916
worker.postMessage(actionHelper(action, getState));
2017
}
2118
return next(action);

0 commit comments

Comments
 (0)