Replies: 7 comments
-
Thanks @ywarezk. I don't fully see why this directive would exist inside @ngrx/component though instead of in userland code I don't know of many people running zoneless applications in practice and those that do are more aware of the implications of it not working as seamlessly because it's not fully supported by the framework itself. |
Beta Was this translation helpful? Give feedback.
-
@brandonroberts
In addition |
Beta Was this translation helpful? Give feedback.
-
@ywarezk that's correct, but I think introducing this directive could be more constraining than helpful. @markostanimirovic has been working on the component package, so I'll defer to him on whether this should be added. We'll revisit sometime after the v14 release, but will leave it open for now. |
Beta Was this translation helpful? Give feedback.
-
Hi @ywarezk, I'm not sure this would be a safe solution for partial exclusion of Also, it can be confusing that we can partially include |
Beta Was this translation helpful? Give feedback.
-
Thanks @markostanimirovic I do think that the
as for the second point it should be well written in the docs about the fact that zoneless means that almost every library that relies on events will not work properly, @Directive({
...
})
export class ZoneLessDirective {
constructor(_ngZone: NgZone) {
if (_ngZone instanceof NoopNgZone) {
throw new Error('Hybrid mode requires you to include zonejs')
}
}
} perhaps @brandonroberts is right and there is no room for those directives here. |
Beta Was this translation helpful? Give feedback.
-
That would be great! You can also create additional helpers for hybrid mode such as registering event listeners outside of the Can't wait to try out your library! 🙂 Btw, I'll convert this issue to discussion. Feel free to share your library in the comment. |
Beta Was this translation helpful? Give feedback.
-
I created a zoneless library the contains a set of Few nice features:
|
Beta Was this translation helpful? Give feedback.
-
Information
When working in zone-less mode, a lot of libraries will not function properly.
Example of an open issue in
@angular/material
: angular/components#9169if you still want to use the vast angular libraries out there, it might be more realistic to work in an hybrid zone-less mode and not completely zone-less.
In this mode you do not remove Zone.js, but you can optimize performance by setting a subtree of components to work outside of the zone.js.
For example with this directive your entire app can be zoneless but when you place angular material components you can wrap them in this directive thus enjoying zoneless performance with support for other libraries.
My suggestion is to add 2 simple directives:
ngrxZoneLess
- gets a template and creates that template outside Zone.jsngrxZoneFull
- gets a template and runs it inside the angular zone.Simplistic example of
ngrxZoneLess
:The usage of that directive would be:
The
ngrxZoneFull
would be similar only usingNgZone.prototype.run
.I think Hybrid mode for zone-less would give you the ability to enjoy the performance gain of zone-less, while avoid troubleshooting libraries that do not support zone-less.
There is the cost the zone.js would have to be included in the bundle, but I think it is worth it.
Describe any alternatives/workarounds you're currently using
Currently I created that directive myself.
I would be willing to submit a PR to fix this issue
Beta Was this translation helpful? Give feedback.
All reactions