]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/hmr.ts
Run videojs outside angular
[github/Chocobozzz/PeerTube.git] / client / src / hmr.ts
CommitLineData
77d07d69
C
1import { NgModuleRef, ApplicationRef } from '@angular/core'
2import { createNewHosts } from '@angularclass/hmr'
3
4export const hmrBootstrap = (module: any, bootstrap: () => Promise<NgModuleRef<any>>) => {
5 let ngModule: NgModuleRef<any>
6 module.hot.accept()
7 bootstrap()
8 .then(mod => ngModule = mod)
9 module.hot.dispose(() => {
10 const appRef: ApplicationRef = ngModule.injector.get(ApplicationRef)
11 const elements = appRef.components.map(c => c.location.nativeElement)
12 const makeVisible = createNewHosts(elements)
13 ngModule.destroy()
14 makeVisible()
15 })
16}