-
-
Notifications
You must be signed in to change notification settings - Fork 2k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
RFC: zone-less / zone-full directives #3446
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. |
@brandonroberts
In addition |
@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. |
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 |
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. |
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. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
The text was updated successfully, but these errors were encountered: