Skip to content

Commit

Permalink
Loading component
Browse files Browse the repository at this point in the history
  • Loading branch information
ItalyPaleAle committed Oct 8, 2020
1 parent 062e3a4 commit 186cd0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ui/src/app/LoadingApp.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="h-screen flex flex-col justify-center text-center">
<div class="text-xl">
<Spinner title="Loading prvt app" />
</div>
</div>

<script>
// Components
import Spinner from './components/Spinner.svelte'
</script>
10 changes: 10 additions & 0 deletions ui/src/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import {wasm} from './stores'

// Svelte app
import App from './App.svelte'
import LoadingApp from './LoadingApp.svelte'

;(async function main() {
// Show the LoadingApp component while the app is initializing
const loading = new LoadingApp({
target: document.body,
})

// Register the service worker and wait for its activation
try {
await navigator.serviceWorker.register('sw.js')
Expand All @@ -25,8 +31,12 @@ import App from './App.svelte'
console.error('Service worker registration failed with ' + err)
}

// Force-enable Wasm in development
await enableWasm(true)

// Remove the loading component
loading.$destroy()

// Initialize the Svelte app and inject it in the DOM
new App({
target: document.body,
Expand Down

0 comments on commit 186cd0b

Please sign in to comment.