ng-redux
ng-redux copied to clipboard
Dispatching actions from targetFunction not working or supported?
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?
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.