Uh oh!
There was an error while loading. Please reload this page.
WIP(core): Proposal: can unload, reload patch modules - #1073
Conversation
googlebot
commented
Apr 29, 2018
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
1 similar comment
googlebot
commented
Apr 29, 2018
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
@mhevery , @robwormald , I have send a message to you on twitter, and I also described the information here. In ng-conf, I described an idea about using I have created a repo here with some basic doc, and a live demo here , https://github-zmawnz.stackblitz.io/ the idea detail is here.AngularElementsA POC of In ng-conf 2018, robwormald described the use cases of
So my idea is add a
How it works
try{Zone.__init__();// monkey patch window APIsplatformBrowserDynamic().bootstrapModule(AppModule).then(ref=>{// Ensure Angular destroys itself on hot reloads.if(window['ngRef']){window['ngRef'].destroy();}window['ngRef']=ref;// Otherise, log the boot error}).catch(err=>console.error(err));}finally{Zone.__unloadAll_patch();// detach the monkey patch, so all window APIs was restored to native one.}
So monkey patched version of window API only exists inside Angular Elements Here is the demo link DEMO. In the demo, there is an angular Element with zone.js, and it will run inside of Please review, thank you very much! |
googlebot
commented
Apr 29, 2018
CLAs look good, thanks! |
1 similar comment
googlebot
commented
Apr 29, 2018
CLAs look good, thanks! |
mhevery
commented
Jun 20, 2018
I am a bit confused. If I understand correctly this PR will remove the My concern is that the cost of patching and un-patching is way more than the cost of Do we have perf numbers that say this makes things better? |
JiaLiPassion
commented
Jun 20, 2018
@mhevery ,
yes, it will remove |
JiaLiPassion
commented
Jun 21, 2018
@mhevery , I did a benchmark test. for(leti=0;i<1000000;i++){zone.run(function(){});}And by average,
|

This is a proposal to support
unload,reloadpatch.Use case: only run specified code into zone.
for example, in current version, the code above, the 1st setTimeout will run into
zone, the 2nd will run intoroot Zone. But evenrootZone still have performance impact. So we may want the 2nd totally run innative setTimeout.in this PR proposal, only
patchallmodulessuch assetTimeout, XHR, promiseinzone.run.and
unPatchthem whenin root zoneor by calling some method like 'runOutsideOfZone` explicitly.Use case: such as angular elements to implement WebComponent. Only run logic with
zone.jspatched inside `angular elements without impact outside world.Proposal. Auto patch when
zone.run, Auto unpatch afterzone.run. Auto repatch whenzone.runagain.To make
unPatchandrePatchfaster, keeppatched delegateandnative delegatereference when callZone.__load_patch, so we only resetdelegatewhenunPatchandrePatch.such as https://github.com/angular/zone.js/compare/master...JiaLiPassion:module?expand=1#diff-75082c639aefcc47b3b8df57c8870867R37
@mhevery , do you think this idea worth a discussion? Thank you.