refactor(apps): migrate RunnableComponent success event to callback prop

Convert from Svelte event dispatcher pattern to callback prop for onSuccess,
aligning with Svelte 5 best practices. Also add initialConfig prop to
ResolveConfig to support onDemandOnly functionality.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-01-20 17:00:43 +00:00
co-authored by Claude Opus 4.5
parent 0e91a86458
commit d4ff12df67
7 changed files with 13 additions and 10 deletions
@@ -83,10 +83,11 @@
)
</script>
{#each Object.keys(components['formcomponent'].initialData.configuration) as key (key)}
{#each Object.entries(components['formcomponent'].initialData.configuration) as [key, initialConfig] (key)}
<ResolveConfig
{id}
{key}
{initialConfig}
bind:resolvedConfig={resolvedConfig[key]}
configuration={configuration[key]}
/>
@@ -97,10 +97,11 @@
/>
{/each}
{#each Object.keys(components['formbuttoncomponent'].initialData.configuration) as key (key)}
{#each Object.entries(components['formbuttoncomponent'].initialData.configuration) as [key, initialConfig] (key)}
<ResolveConfig
{id}
{key}
{initialConfig}
bind:resolvedConfig={resolvedConfig[key]}
configuration={configuration[key]}
/>
@@ -50,7 +50,7 @@
{runnable}
wrapperClass="hidden"
recomputableByRefreshButton={runnable.autoRefresh ?? true}
on:success={onSuccess}
onSuccess={(_r) => onSuccess()}
{outputs}
>
{@render children?.()}
@@ -169,7 +169,7 @@
let nhash = typeof value != 'object' ? value : sum(value)
lastExprHash = nhash
} else if (input?.type == 'evalv2') {
// console.log('evalv2', onDemandOnly, field)
// console.log('evalv2', onDemandOnly, field, exportValueFunction, key)
if (onDemandOnly && exportValueFunction) {
value = (args?: any) => {
return evalExpr(input as EvalV2AppInput, args)
@@ -55,7 +55,7 @@
{:else}
{#if debug}
<pre class="text-2xs">
key: {key}
key: {key}
{JSON.stringify({ r: resolvedConfig })}
{JSON.stringify(configuration)}</pre
>
@@ -72,6 +72,7 @@
overrideCallback?: (() => CancelablePromise<void>) | undefined
overrideAutoRefresh?: boolean
replaceCallback?: boolean
onSuccess?: (result: any) => void
children?: import('svelte').Snippet
nonRenderedPlaceholder?: import('svelte').Snippet
}
@@ -104,7 +105,8 @@
overrideAutoRefresh = false,
replaceCallback = false,
children,
nonRenderedPlaceholder
nonRenderedPlaceholder,
onSuccess
}: Props = $props()
const {
@@ -685,7 +687,7 @@
delete $errorByComponent[id]
if (dispatchSuccess) {
dispatch('success', result)
onSuccess?.(result)
}
// callbacks?.done(res)
}
@@ -223,7 +223,6 @@
if (!sideEffect) return
if (sideEffect.selected == 'none') return
await executeSideEffect(sideEffect, success, errorMessage)
}
@@ -389,8 +388,8 @@
initializing = false
}}
on:success={(e) => {
onSuccess(e.detail)
onSuccess={(result) => {
onSuccess(result)
handleSideEffect(true)
}}
on:handleError={(e) => handleSideEffect(false, e.detail)}