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

AngularJS too many digest iterations when using bound thunk action function #110

Open
frankandrobot opened this issue Oct 28, 2016 · 1 comment

Comments

@frankandrobot
Copy link

frankandrobot commented Oct 28, 2016

I'm getting this error when I add a bound thunk action to an attribute.

angular.js:68Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

It is probably an angular issue but here's the scenario:

// setup controller
const unsubscribe = $ngRedux.connect(
      state => this.mapStateToThis(state, privileges),
   ),
   // this auto-injects the actions bound to ngRedux.dispatch
   Object.assign({}, Actions, AsyncActions)
)(this)

// thunk action creator
cancelSave(appUtilization) {
      return dispatch => {
        dispatch(AppActions.resetApp());
        appUtilization.$setPristine();
      }
 }

// template that breaks
<save-settings-panel cancel-action="$ctrl.cancelSave($ctrl.appUtilization)"></save-settings-panel>

Update: after doing a bit of research, it seems that #cancelSave will be called on each iteration of the digest loop. (See for example, http://stackoverflow.com/a/26783778/555493) Hence, the digest error.

The question then is how am I supposed to use #cancelSave without creating a proxy function in the controller?

@AntJanus
Copy link
Collaborator

AntJanus commented Jan 8, 2018

@frankandrobot were you able to resolve this issue? I don't believe it's ng-redux related. My guess is that whatever is calling $ctrl.cancelSave is doing so at the wrong time or in the wrong place?

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