platform icon indicating copy to clipboard operation
platform copied to clipboard

Dispatch an action outside of ngZone

Open s-uds opened this issue 5 years ago • 1 comments

This is a...

  • [x] feature request
  • [ ] bug report
  • [ ] usage question

What toolchain are you using for transpilation/bundling?

  • [x] @angular/cli
  • [ ] Custom @ngTools/webpack
  • [ ] Raw ngc
  • [ ] SystemJS
  • [ ] Rollup
  • [ ] Other

Environment

NodeJS Version: 13.1.0 Typescript Version: 3.4.5 Angular Version: 8.2.8 @angular-redux/store version: 10.0.0 @angular/cli version: 8.3.6 OS: macOS Mojave

Expected Behaviour:

(Originally posted here: https://github.com/angular-redux/store/issues/565)

Hi,

I noticed that dispatch() checks if in the Angular zone or not and always calls ngZone.run if not (source: https://github.com/angular-redux/platform/blob/master/packages/store/src/components/root-store.ts#L84).

However, I wish to dispatch an action from a zone.runOutsideAngular() statement (much like described here: https://github.com/ngxs/store/issues/487)

Is there any known workaround for this? Could it be featured as an additional option (like: https://github.com/ngxs/store/issues/487#issuecomment-453637688)

Thanks a lot!

s-uds avatar Dec 12 '19 11:12 s-uds

PR available here for review https://github.com/angular-redux/platform/pull/106

mengdi avatar Dec 16 '19 14:12 mengdi