aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/hmr.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-12 14:45:42 +0100
committerChocobozzz <me@florianbigard.com>2017-12-12 14:45:42 +0100
commit77d07d690968a9631fc0c8bafbaebd27a5ebaab6 (patch)
treed513fdc81ed82b60edaa0b683f5f8d8dc9fc9db3 /client/src/hmr.ts
parentb2731bff2834fb6aacf166cf435030bf96eb12f3 (diff)
downloadPeerTube-77d07d690968a9631fc0c8bafbaebd27a5ebaab6.tar.gz
PeerTube-77d07d690968a9631fc0c8bafbaebd27a5ebaab6.tar.zst
PeerTube-77d07d690968a9631fc0c8bafbaebd27a5ebaab6.zip
Add hmr
Diffstat (limited to 'client/src/hmr.ts')
-rw-r--r--client/src/hmr.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/client/src/hmr.ts b/client/src/hmr.ts
new file mode 100644
index 000000000..4d707a250
--- /dev/null
+++ b/client/src/hmr.ts
@@ -0,0 +1,16 @@
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}