mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 16:02:14 +00:00
fix reactivity issue wrt to updating worldStore on state output already existing
This commit is contained in:
@@ -70,6 +70,8 @@
|
||||
|
||||
$: lastInput && $worldStore && debounce(handleConnection)
|
||||
|
||||
$: console.log('worldStore', $worldStore, id)
|
||||
|
||||
$: lastInput &&
|
||||
lastInput.type == 'template' &&
|
||||
$stateId &&
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
}
|
||||
|
||||
function setOutput(v: any) {
|
||||
// console.log('setnr', id)
|
||||
outputs?.result?.set(v, true)
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,11 @@
|
||||
runnable && runnable.type === 'runnableByName' ? runnable.inlineScript?.refreshOn ?? [] : []
|
||||
|
||||
function refreshIfAutoRefresh(_src: string) {
|
||||
// console.debug(`Triggering refreshing ${id} because ${_src}`)
|
||||
const refreshEnabled =
|
||||
autoRefresh && ((recomputeOnInputChanged ?? true) || refreshOn?.length > 0)
|
||||
if (refreshEnabled && $initialized.initialized) {
|
||||
// console.debug(`Refreshing ${id} because ${_src} (enabled)`)
|
||||
setDebouncedExecute()
|
||||
}
|
||||
}
|
||||
@@ -153,6 +155,7 @@
|
||||
}
|
||||
|
||||
async function executeComponent(noToast = false, inlineScriptOverride?: InlineScript) {
|
||||
console.debug(`Executing ${id}`)
|
||||
if (runnable?.type === 'runnableByName' && runnable.inlineScript?.language === 'frontend') {
|
||||
loading = true
|
||||
try {
|
||||
@@ -301,6 +304,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('setr', id)
|
||||
|
||||
outputs.result?.set(res)
|
||||
|
||||
result = res
|
||||
|
||||
@@ -230,6 +230,10 @@ console.log(ctx.email)
|
||||
if (!state.foo) { state.foo = 0 }
|
||||
state.foo += 1
|
||||
|
||||
// for reactivity to work, you need to assign a value and not modify it in place
|
||||
// e.g: state.foo.push(1) will not work but 'state.foo = [...state.foo, 1]' will.
|
||||
// you may also just reassign as next statement 'state.foo = state.foo'
|
||||
|
||||
// you can also navigate (goto), recompute a script (recompute), or set a tab (setTab)
|
||||
|
||||
return state.foo`,
|
||||
|
||||
@@ -41,7 +41,6 @@ export function buildWorld(context: Record<string, any>): Writable<World> {
|
||||
|
||||
function newOutput<T>(id: string, name: string, previousValue: T) {
|
||||
if (outputsById[id]?.[name]) {
|
||||
writableWorld?.update((x) => x)
|
||||
return outputsById[id][name]
|
||||
}
|
||||
let o = newWorld.newOutput(id, name, stateId, previousValue)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { switchWorkspace, userWorkspaces, workspaceStore } from '$lib/stores'
|
||||
import { classNames } from '$lib/utils'
|
||||
import { Building, Cog } from 'lucide-svelte'
|
||||
import { Building } from 'lucide-svelte'
|
||||
|
||||
import Menu from '../common/menu/Menu.svelte'
|
||||
import { faCog, faPlus } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
Reference in New Issue
Block a user