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 doesn't subscribe dispatch the current state? #1707

Closed
mAAdhaTTah opened this issue May 9, 2016 · 3 comments
Closed

Why doesn't subscribe dispatch the current state? #1707

mAAdhaTTah opened this issue May 9, 2016 · 3 comments

Comments

@mAAdhaTTah
Copy link

I'm working on integrating redux into a project, and I'm setting up all of my view components (not using React here) to get passed the state and render/update themselves based on it. I know this is a fairly minor issue, but I'd like to know why the state object isn't passed an argument to the subscribe callback.

For example, what I'd like to do is this:

const store = createStore(reducer, state);
store.subscribe(view.render);

But what I have to do is this:

const store = createStore(reducer, state);
store.subscribe(() => {
    view.render(store.getState());
});

Is there a reason for this?

@rossipedia
Copy link

This has been discussed previously:

#1513
#303

TL;DR: Being notified that a store has changed is orthogonal to getting the current state. Read the above referenced issues for more details.

@mAAdhaTTah
Copy link
Author

Fair enough, thanks for pointing me in the right direction.

@gaearon
Copy link
Contributor

gaearon commented May 9, 2016

FWIW we can finally allow this after #1702 because store enhancers are exposed to a subset of API without subscribe.

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

3 participants