Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import { NgModuleRef, ApplicationRef } from '@angular/core';
  2. import { createNewHosts } from '@angularclass/hmr';
  3.  
  4. export const hmrBootstrap = (
  5. module: any,
  6. bootstrap: () => Promise<NgModuleRef<any>>
  7. ) => {
  8. let ngModule: NgModuleRef<any>;
  9. module.hot.accept();
  10. bootstrap().then(mod => {
  11. if (mod) {
  12. ngModule = mod;
  13. }
  14. });
  15. module.hot.dispose(() => {
  16. const appRef: ApplicationRef = ngModule.injector.get(ApplicationRef);
  17. const elements = appRef.components.map(c => c.location.nativeElement);
  18. const makeVisible = createNewHosts(elements);
  19. ngModule.destroy();
  20. makeVisible();
  21. });
  22. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement