From f586a172964c67c2967fbd4c974fc401564331fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Syn=C3=A1=C4=8Dek?= Date: Fri, 25 Dec 2020 14:47:58 +0100 Subject: [PATCH] feature: track chunk loading in UI --- lib/frontend/components/Input.svelte | 7 +++++++ lib/frontend/components/InputContainer.svelte | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/lib/frontend/components/Input.svelte b/lib/frontend/components/Input.svelte index dbc882d..b0cc5e5 100644 --- a/lib/frontend/components/Input.svelte +++ b/lib/frontend/components/Input.svelte @@ -26,6 +26,9 @@ export let error export let pending export let pendingRequest + export let onModuleLoadStart + export let onModuleLoadStop + export let onModuleLoadError let value = '' $: value = error && pendingRequest && pendingRequest.url || '' @@ -45,10 +48,14 @@ e.preventDefault() try { + onModuleLoadStart() const module = await import('../actions') + onModuleLoadStop() + module.createEvent(value, { logger }) value = '' } catch (importError) { + onModuleLoadError(importError) console.error(importError) } } diff --git a/lib/frontend/components/InputContainer.svelte b/lib/frontend/components/InputContainer.svelte index f0d75c2..5d13a35 100644 --- a/lib/frontend/components/InputContainer.svelte +++ b/lib/frontend/components/InputContainer.svelte @@ -8,6 +8,10 @@ $: pendingRequest = $requestStore $: status = $parseStatusStore $: swStatus = $swStatusStore + + const handleModuleLoadStart = () => parseStatusStore.set('Loading application data.') + const handleModuleLoadEnd = () => parseStatusStore.set(null) + const handleModuleLoadError = (error) => parseStatusStore.set('Failed to load application data.')
@@ -15,6 +19,9 @@ {pending} {pendingRequest} {error} + onModuleLoadStart={handleModuleLoadStart} + onModuleLoadStop={handleModuleLoadEnd} + onModuleLoadError={handleModuleLoadError} />