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

Dispatching actions from targetFunction not working or supported? #133

Open
tfrijsewijk opened this issue Apr 26, 2017 · 1 comment
Open

Comments

@tfrijsewijk
Copy link

I am connecting to redux using connect() and within the targetFunction I want to dispatch an action. I see the action being dispatched in the Redux Inspector Chrome extension, but the state selector is not being called. When I dispatch the action OUTSIDE of the targetFunction, everything works as expected.

See this plunker: https://plnkr.co/edit/oIujbcjwrOSr2egsmSWS?p=preview

I found several examples and tutorials doing what I did in the plunker. I can only assume they are not publishing non-working examples.. So, is this a bug in ngRedux or not supported at all? Is it considered bad practice dispatching actions from the targetFunction?

@hangzho
Copy link

hangzho commented Aug 4, 2017

What I found is that the targetFunction will be called once when the controller is initialized. The dispatching actions doesn't work. However, later, if you change the state and targetFunction gets called again, the dispatching actions should be working well.

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

2 participants