Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does the return value of fn get dispatched? #3

Open
shaula opened this issue Nov 9, 2017 · 0 comments
Open

Why does the return value of fn get dispatched? #3

shaula opened this issue Nov 9, 2017 · 0 comments

Comments

@shaula
Copy link

shaula commented Nov 9, 2017

I'm using redux-subscribe with plain redux (no react, no vdux or whatever).

Since I'm a redux beginner, I don't understand this line of your code:

Index: node_modules/redux-subscribe/lib/index.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- node_modules/redux-subscribe/lib/index.js	(revision )
+++ node_modules/redux-subscribe/lib/index.js	(revision )
@@ -85,6 +85,7 @@
 
                 if (prev !== next) {
                   (0, _foreach2.default)(function (fn) {
+                    // Why is the return value of fn dispatched again?
                     return dispatch(fn({ path: path, prev: prev, next: next }));
                   }, subscriptions[path]);
                 }

My call to subscribe looks like this:

store.dispatch(subscribe('feature', 'feature', () => {
	renderFeature();
	return {type: null};
}));

But initially I tried doing:

store.dispatch(subscribe('feature', 'feature', renderFeature));

...which failed as the dispatch function is passed a null and cannot find a property type on it. As a result I return {type: null} from my wrapped render function. Am I doing something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant