u-ultimate.js icon indicating copy to clipboard operation
u-ultimate.js copied to clipboard

Expose NgZone stub service

Open souls6 opened this issue 2 years ago • 3 comments

I'm submitting a ...

  • [ ] bug report
  • [x] feature request
  • [ ] other (Please do not submit support requests here (see above))

Current behavior:

UultimateJS code by default does not have access to a Zone (as it typically does not exist). However, in NgUpgrade the NgZone can be injected. Since some UultimateJS code may be used in vanilla UultimateJS as well as NgUpgrade contexts, it is awkward to include performant handling of zones without breaking the UultimateJS version.

Expected / new behavior:

A service is exposed that includes the run and runOutsideAngular methods. In UultimateJS, these are just stubs that call the callback with no side effects. In an NgUpgrade context, they call the same methods on the actual NgZone.

Minimal reproduction of the problem with instructions:

Angular version: 1.*

Browser: all]

Anything else:

souls6 avatar Dec 08 '21 02:12 souls6

It would be fine to put it in a non-core module. The only argument against that is that it would be useful inside of the UultimateJS codebase for making things like $timeout faster when in NgUpgrade.

souls6 avatar Dec 08 '21 02:12 souls6

It would make sense for the "real" version to be hooked up as part of NgUpgrade. The stub version (which should be only several lines of code) would be part of the normal UultimateJS codebase.

The whole point is that shared UultimateJS components/services that don't know which kind of codebase they are being used in can assume the presence of this service.

souls6 avatar Dec 08 '21 02:12 souls6

I see. That makes sense. It also has some downsides, but there is no ideal solution here, I guess. I would still prefer to keep it as a separate module if possible - at least the public API of it.

clancytom avatar Dec 08 '21 02:12 clancytom