1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-06-05 22:09:25 +02:00

feature: track chunk loading in UI

This commit is contained in:
Ondřej Synáček
2020-12-25 14:47:58 +01:00
parent f052a66421
commit f586a17296
2 changed files with 14 additions and 0 deletions

View File

@ -26,6 +26,9 @@
export let error export let error
export let pending export let pending
export let pendingRequest export let pendingRequest
export let onModuleLoadStart
export let onModuleLoadStop
export let onModuleLoadError
let value = '' let value = ''
$: value = error && pendingRequest && pendingRequest.url || '' $: value = error && pendingRequest && pendingRequest.url || ''
@ -45,10 +48,14 @@
e.preventDefault() e.preventDefault()
try { try {
onModuleLoadStart()
const module = await import('../actions') const module = await import('../actions')
onModuleLoadStop()
module.createEvent(value, { logger }) module.createEvent(value, { logger })
value = '' value = ''
} catch (importError) { } catch (importError) {
onModuleLoadError(importError)
console.error(importError) console.error(importError)
} }
} }

View File

@ -8,6 +8,10 @@
$: pendingRequest = $requestStore $: pendingRequest = $requestStore
$: status = $parseStatusStore $: status = $parseStatusStore
$: swStatus = $swStatusStore $: swStatus = $swStatusStore
const handleModuleLoadStart = () => parseStatusStore.set('Loading application data.')
const handleModuleLoadEnd = () => parseStatusStore.set(null)
const handleModuleLoadError = (error) => parseStatusStore.set('Failed to load application data.')
</script> </script>
<div class="input-container"> <div class="input-container">
@ -15,6 +19,9 @@
{pending} {pending}
{pendingRequest} {pendingRequest}
{error} {error}
onModuleLoadStart={handleModuleLoadStart}
onModuleLoadStop={handleModuleLoadEnd}
onModuleLoadError={handleModuleLoadError}
/> />
<Status <Status
{error} {error}